<?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>Beacon adevrtising switch over while button pressing?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46456/beacon-adevrtising-switch-over-while-button-pressing</link><description>Hi, 
 I have been trying for switching advertising parameters like m_beacon_info1[6]=0x00 to 0xff when button pressing.After 10 advertising ,the parameter back to normal as m_beacon_info1[8]=0x00. as I m working with nrf52840 sdk15.2 BLE_APP_BEACON. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Apr 2019 19:40:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46456/beacon-adevrtising-switch-over-while-button-pressing" /><item><title>RE: Beacon adevrtising switch over while button pressing?</title><link>https://devzone.nordicsemi.com/thread/184403?ContentTypeID=1</link><pubDate>Mon, 29 Apr 2019 19:40:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b9a753e-8ca7-4ae8-85bf-880975d4cc7b</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am not sure what you are trying to achieve.&lt;/p&gt;
&lt;p&gt;My guess is that you want to advertise with&amp;nbsp;m_beacon_info1[6] equal to 0x00 by default and when a button is pressed you want to send 10 advertising packets with&amp;nbsp;&lt;span&gt;m_beacon_info1[6] equal to 0xff&lt;/span&gt;&amp;nbsp; before going back to the default advertising data.&lt;/p&gt;
&lt;p&gt;I took a look at your code, and there are some faults. This won&amp;#39;t work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;for(i=0;i&amp;lt;10;i++)
{
    err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
    NRF_LOG_INFO(&amp;quot;Beacon.&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Running &lt;em&gt;sd_ble_gap_adv_start()&lt;/em&gt; two times (or more) in a row will not work. If you look at the explanatory text for&amp;nbsp;&lt;em&gt;sd_ble_gap_adv_start()&amp;nbsp;&lt;/em&gt;inside &lt;em&gt;ble_gap.h, &lt;/em&gt;you&amp;nbsp; will see that the function returns&amp;nbsp;NRF_ERROR_INVALID_STATE if you run it twice in a row.&lt;/p&gt;
&lt;p&gt;If you want to send a specific amount of advertising packets I would recommend you&amp;nbsp;implement it in this manner:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;When the button is pushed you stop the advertising, update the advertising data (&lt;span&gt;m_beacon_info1[6] equal to 0xff&lt;/span&gt;) and start the advertising again&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Then you Start a timer&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;In order to send out x amount of advertising packets, you have to configure the duration of the timer based on the advertising interval&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;When the timer expires you&lt;span&gt;&amp;nbsp;&lt;/span&gt;stop the advertising, update the advertising data (&lt;span&gt;m_beacon_info1[6] equal to 0x00&lt;/span&gt;) and start the advertising again&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Beacon adevrtising switch over while button pressing?</title><link>https://devzone.nordicsemi.com/thread/183751?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 11:17:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6ac7e78-f43c-46cd-889c-b33b308f2add</guid><dc:creator>mayuri</dc:creator><description>&lt;p&gt;Hi simon,&lt;/p&gt;
&lt;p&gt;yes you are correct. Thanks for your quick reply&lt;/p&gt;
&lt;p&gt;1) First two points , it works fine.&lt;/p&gt;
&lt;p&gt;2) &lt;strong&gt;3rd point is my problem&lt;/strong&gt;. i cant see the advertising packets as&amp;nbsp;&lt;strong&gt;m_beacon_info1[6]&amp;nbsp;is&amp;nbsp;0xff in nrf connect app.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;how should i send 10 advertising packets with&amp;nbsp;m_beacon_info1[6]&amp;nbsp;is&amp;nbsp;0xff?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; how should i count advertising&amp;nbsp;?&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3) Immediately the packets changed as&amp;nbsp;m_beacon_info1[6] to 0x00.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Here i tried&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;if(flag==1)&amp;nbsp;&lt;strong&gt; &amp;nbsp;interrupt handler&lt;/strong&gt;&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();&lt;br /&gt; uint32_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;/p&gt;
&lt;p&gt;&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;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Beacon adevrtising switch over while button pressing?</title><link>https://devzone.nordicsemi.com/thread/183686?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 08:35:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95a54de9-8eb0-4562-8234-f158f5fb62fd</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I will make sure I understand you correctly before I proceed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;You start advertising with&amp;nbsp;m_beacon_info1[6]=0x00&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A&amp;nbsp;button is pressed, and&amp;nbsp;m_beacon_info1[6] is set to 0xff&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Then the device sends out 10 advertising packets and&amp;nbsp;m_beacon_info1[6]&amp;nbsp;is&amp;nbsp;0xff&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Have you confirmed that the advertising packet contains this value, by using a sniffer or similar?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;When the next advertising packet is sent out,&amp;nbsp;m_beacon_info1[6]&amp;nbsp;is equal to 0x00&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Have you confirmed that the advertising packet contains this value, by using a sniffer or similar?&lt;strong&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;Do I understand you correctly?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>