<?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>Stop advertising is blocking?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25304/stop-advertising-is-blocking</link><description>I&amp;#39;m trying to regularly change some advertising parameters ( ble_gap_adv_params_t.type ). The only way i can see to do so, is by stopping and starting advertising.
However, I noticed that stopping advertising ( sd_ble_gap_adv_stop() ) takes about 5-30ms</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Sep 2017 09:35:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25304/stop-advertising-is-blocking" /><item><title>RE: Stop advertising is blocking?</title><link>https://devzone.nordicsemi.com/thread/99715?ContentTypeID=1</link><pubDate>Thu, 21 Sep 2017 09:35:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ce0a2b1-f9f6-459a-898e-ea1859e01fe4</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;Hmm, for me, the function gets executed in an &lt;code&gt;app_sched_execute()&lt;/code&gt;, in the main loop. I also measured it like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_gpio_pin_set(TEST_PIN);
err_code = sd_ble_gap_adv_stop();
nrf_gpio_pin_clear(TEST_PIN);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Optimization: -Os&lt;/p&gt;
&lt;p&gt;A lot of other things are happening too in the meanwhile though, like meshing.
I guess I&amp;#39;ll try to pinpoint when it takes so long to execute.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stop advertising is blocking?</title><link>https://devzone.nordicsemi.com/thread/99716?ContentTypeID=1</link><pubDate>Thu, 21 Sep 2017 07:29:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3db015bc-e8eb-4895-8ac4-4db94f59c79b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I tried it with SDK 11 and S132 v2.0.0 and v2.0.1. The longest execution time I measured was ~55us. The time seems to vary slightly depending on compiler optimization settings and whether the advertising has already been stopped. I got 55us with optimization set to -O0. The code I used was the BLE template example. And I simply added this code in main() right before the main while() loop:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_delay_ms(500);
nrf_gpio_pin_clear(LED_4);
sd_ble_gap_adv_stop();
nrf_gpio_pin_set(LED_4);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where in your code do you measure the time?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stop advertising is blocking?</title><link>https://devzone.nordicsemi.com/thread/99714?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2017 14:57:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6d8fd04-b074-4add-9c00-3feeac1b20bb</guid><dc:creator>bart</dc:creator><description>&lt;p&gt;I added &lt;code&gt;gpio_set&lt;/code&gt; and &lt;code&gt;gpio_clear&lt;/code&gt; around it, and measured the pin with a logic analyzer. Interval is set to 160 (100ms).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stop advertising is blocking?</title><link>https://devzone.nordicsemi.com/thread/99713?ContentTypeID=1</link><pubDate>Wed, 20 Sep 2017 11:24:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a03e8d5-27e6-4261-825e-fa0ef79fdec1</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;How do you measure this? There is not supposed to be any blocking code in sd_ble_gap_adv_stop().&lt;/p&gt;
&lt;p&gt;One tip is to use &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html#gaddbb12e078d536ef2e93b41d77ff6243"&gt;sd_ble_gap_adv_data_set()&lt;/a&gt; directly to immediatly set the advertising packet without stopping and starting advertising.&lt;/p&gt;
&lt;p&gt;EDIT: I didn&amp;#39;t read your question carefully enough. If you change the &lt;em&gt;type&lt;/em&gt; parameter from e.g. connectable to unconnectable you cannot use sd_ble_gap_adv_data_set().&lt;/p&gt;
&lt;p&gt;But I&amp;#39;m also curious about what advertising interval you use?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>