<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46230/change-beacon-advertising-parameters-while-button-pressed</link><description>Hi, 
 
 I m using NRF52840 as a Beacon. i m using SDK15.2 ble_app_beacon.Advertising is works fine. Now i want to change advertising parameter while button pressed. Here is my code.I m not getting the result.Please guide me to solve this issue</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Apr 2019 04:28:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46230/change-beacon-advertising-parameters-while-button-pressed" /><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/184202?ContentTypeID=1</link><pubDate>Mon, 29 Apr 2019 04:28:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0cced1b-bc57-486d-bfe3-5392d0d22982</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;i tried app timer..i re initialized parameter&amp;nbsp; (&lt;span&gt;advertising_init_new();&amp;nbsp; )&amp;nbsp;&lt;/span&gt;holds after changing the (&lt;span&gt;advertising_init();).....&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/184031?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2019 10:36:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40bd269c-821d-4e1b-8de4-261843d42d75</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I would rather recommend that you setup a timer (app_timer can be used - see &lt;a href="https://devzone.nordicsemi.com/tutorials/b/software-development-kit/posts/application-timer-tutorial"&gt;application timer tutorial&lt;/a&gt;) that change the advertising back after n times the advertising interval.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/183393?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 09:57:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb27d8ba-f3bf-4e4e-b2ea-d328c2936425</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;Thanks for your valuable recommend. i changed to interrupt handler as you said&lt;/p&gt;
&lt;p&gt;for (;;)&lt;br /&gt;{&lt;br /&gt; //advertising_start();&lt;br /&gt; idle_state_handle();&lt;br /&gt; if(flag==1)&lt;br /&gt; {&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; err_code = sd_ble_gap_adv_stop(m_adv_handle);&lt;br /&gt; nrf_drv_gpiote_out_toggle(14);&lt;br /&gt; device_name_get();&lt;br /&gt; advertising_init_new();&amp;nbsp; &amp;nbsp; // reinitialised beacon parameteruint32_t i;&lt;br /&gt; err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);&lt;br /&gt; NRF_LOG_INFO(&amp;quot;Beacon.&amp;quot;);&lt;br /&gt; for(i=0;i&amp;gt;100;i++)&lt;br /&gt; {&lt;br /&gt; //i=0;&lt;br /&gt; idle_state_handle();&lt;br /&gt; i++;&lt;br /&gt; }&lt;br /&gt; advertising_init();&lt;br /&gt; nrf_drv_gpiote_out_toggle(14);&lt;br /&gt; flag=0;&lt;br /&gt; }&lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/46230/change-beacon-advertising-parameters-while-button-pressed/183187"]What do you mean by this?&amp;nbsp;[/quote]
&lt;p&gt;i mean that, after pressing button,the next 10 advertising will be re initialed advertising&amp;nbsp; (&lt;span&gt;advertising_init_new();&amp;nbsp;&amp;nbsp;).then it back to normal advertising&amp;nbsp;mode.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;now i checked in NRFconnect app..i can see the&amp;nbsp;re initialed advertising value by 1sec. then it changed immediately.i want to check advertising count. how do i check advertising&amp;nbsp;count?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/183187?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 15:00:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb19ea35-3d0f-41de-b224-d616f7f629a2</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Mayuri"]i stuck in 10 advertising.[/quote]
&lt;p&gt;What do you mean by this?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is not recommended to spend long time inside interrupt handlers, I would recommend that you do the work in main loop and use flags that you set in the handlers, to tell what should happen in main context.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/183065?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 09:18:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7e1f61b-120b-4d03-9ea2-d87a13c5fd3d</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;hi jorgen ,&lt;/p&gt;
&lt;p&gt;void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;br /&gt; err_code = sd_ble_gap_adv_stop(m_adv_handle);&lt;br /&gt; nrf_drv_gpiote_out_toggle(14);&lt;br /&gt; device_name_get();&lt;br /&gt; advertising_init1();&amp;nbsp; &amp;nbsp;// Re_initialise the parameter&lt;br /&gt; uint16_t i;&lt;br /&gt; err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);&lt;br /&gt; NRF_LOG_INFO(&amp;quot;Beacon.&amp;quot;);&lt;br /&gt; nrf_delay_ms(1000);&lt;br /&gt; advertising_init();&amp;nbsp; // after 10 advertising set to back to normal&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;All r works fine.&lt;/p&gt;
&lt;p&gt;Except one thing.&lt;/p&gt;
&lt;p&gt;while pressing button,i reinitialized advertising data (&lt;span&gt;advertising_init1();)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;then next 10 advertising the parameters should hold and then its back to its original condition(&lt;span&gt;advertising_init();&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;i stuck in 10 advertising. please help me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/183038?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 08:45:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11dec47e-774e-4a4a-916f-ce99726bd192</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you want advertising data to change, you need to call the functions that initialize advertising data again. It is not sufficient to change the variable that was used when first initializing advertising data. The data is copied to internal buffers in the stack.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182843?ContentTypeID=1</link><pubDate>Sat, 20 Apr 2019 05:16:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de5457db-e80f-4371-9fde-b8d0a3054aa1</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;Hi Jorgan,,&lt;/p&gt;
&lt;p&gt;Please reply me asap..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182747?ContentTypeID=1</link><pubDate>Thu, 18 Apr 2019 13:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6859b04e-27f3-4776-9938-e9d3c42bb840</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i tried interrupt while pressing button i changed beacon parameters, but i checked in my app,the value should changed.&lt;/p&gt;
&lt;p&gt;But Led works as button pressed.&lt;/p&gt;
&lt;p&gt;void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)&lt;br /&gt;{&lt;br /&gt; ret_code_t err_code;&lt;/p&gt;
&lt;p&gt;nrf_drv_gpiote_out_toggle(14);&lt;br /&gt; m_beacon_info1[6]=0xff;&lt;/p&gt;
&lt;p&gt;NRF_LOG_INFO(&amp;quot;Beacon.&amp;quot;);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Should i add anything in in_pin_handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182554?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2019 09:25:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:638951dc-fa2e-4a6c-9ee9-616856ffce5b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is a tutorial explaining how to use the button handling library in &lt;a href="https://github.com/bjornspockeli/nRF52_peripherals_tutorial#3-buttons---button-handler-library"&gt;this GitHub repository&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182507?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2019 07:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31e684d2-4eb5-4884-b44d-e5f9e444859f</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;hi jorgen&lt;/p&gt;
&lt;p&gt;how can i change my code to attain my result? waiting for your reply&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182440?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 15:16:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3ecb621-dcdc-4f58-9a2a-aa01af177831</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;hi jorgen,&lt;/p&gt;
&lt;p&gt;would you have any example program for button interrupts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182415?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 13:42:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caac5c55-703f-4409-9bbd-d7a4da4da5b3</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you want the advertising data to change on button press, you need to implement GPIOTE/app_button to get interrupts whenever the button is pressed, and then update the advertising data in the handler.&lt;/p&gt;
&lt;p&gt;You are not doing this in your code, so it will not change after startup.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182397?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 13:03:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57ab257e-b614-4dc7-bae2-1f0e4e0f9232</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;yes ,i can check button input status in&amp;nbsp;&lt;span&gt;advertising_init(). and i called once in the function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void advertising_init(void) {
  uint32_t err_code;
  ble_advdata_t advdata;
  uint32_t pin_value;
  uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
/* Beacon Configuration*/
  ble_advdata_manuf_data_t manuf_specific_data;

  manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
  m_beacon_info1[0]=APP_DEVICE_TYPE;                       
  m_beacon_info1[1]=APP_ADV_DATA_LENGTH;

  /* service id*/
  for(int i=5;i&amp;gt;1;i--)
  {
    m_beacon_info1[i]=*service_uid_pointer++;
  }

  pin_value = nrf_gpio_pin_read(11); //check button status
   if(pin_value==0)
   {
     m_beacon_info1[6]=0x00;      
      nrf_gpio_pin_toggle(14);
                                 // Aided
   }
   else
   {
     m_beacon_info1[6]=0xff;
    // nrf_gpio_pin_clear(14);
   }

 // m_beacon_info1[6]=0x00;                                  // Aided
  m_beacon_info1[7]=0xff;                                  //Reserved id
  m_beacon_info1[8]=0xff;                                  // reserved id
  //m_beacon_info1[18]=0x20;                                 //Major 1st byte
  m_beacon_info1[18]=0x54; 
  m_beacon_info1[19]=0x57;  //Major 2nd byte
  m_beacon_info1[20]=0x4F;                                 //Minor 1st byte
  m_beacon_info1[21]=0x54; 
  //m_beacon_info1[21]=0x55;//Minor  2nd byte
  m_beacon_info1[22]=0xC3;                                 //Rssi @1m

 manuf_specific_data.data.p_data = (uint8_t *)m_beacon_info1;
 manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH;
  // Build and set advertising data.
  memset(&amp;amp;advdata, 0, sizeof(advdata));

  advdata.name_type = BLE_ADVDATA_NO_NAME;
  advdata.flags = flags;
  advdata.p_manuf_specific_data = &amp;amp;manuf_specific_data;

  // Initialize advertising parameters.
  memset(&amp;amp;m_adv_params, 0, sizeof(m_adv_params));

  m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
  m_adv_params.p_peer_addr = NULL;                                                              // Undirected advertisement.
  m_adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;                                               //Filter policy
  m_adv_params.interval = NON_CONNECTABLE_ADV_INTERVAL;
 // m_adv_params.channel_mask[4];
 // m_adv_params.channel_mask[4] = 0xA0;

  m_adv_params.duration = 0;                                                                     // Never time out.

  err_code = ble_advdata_encode(&amp;amp;advdata, m_adv_data.adv_data.p_data, &amp;amp;m_adv_data.adv_data.len);
  APP_ERROR_CHECK(err_code);

  err_code = sd_ble_gap_adv_set_configure(&amp;amp;m_adv_handle, &amp;amp;m_adv_data, &amp;amp;m_adv_params);
  APP_ERROR_CHECK(err_code);
}

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182395?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 12:47:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1692e663-93a6-45eb-bb70-c27137623b26</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You are only changing this variable inside&amp;nbsp;advertising_init(), and you only call this function once. Are you seeing the change if you hold the button before powering the device?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182387?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 12:27:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e32c5552-44dc-4e6f-aab2-0e19f52c5c4e</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;hi Jorgen,&lt;/p&gt;
&lt;p&gt;Thanks for ur reply,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;while pressing button,the beacon parameters changed from m_beacon_info1[6]=0x00; to 0xFF. Next 10 advertisement the value should not changed.Then it continues to value 0x00..the button acts as an alarm.&lt;/p&gt;
&lt;p&gt;While debugging the value should changed from 00 to FF..But in running condition still remains it same..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: change Beacon advertising parameters while button pressed?</title><link>https://devzone.nordicsemi.com/thread/182384?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 12:19:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0f5d0bd-1f61-4239-9261-3f1c5ab74591</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]I m not getting the result[/quote]
&lt;p&gt;What result do you expect to get, and what result do you actually get? Should the advertising only change while you hold the button, or should it stay changed after you release the button as well?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>