<?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>Is race condition possible when stopping advertising?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32655/is-race-condition-possible-when-stopping-advertising</link><description>Is race condition possible when stopping advertising? 
 I need to disable BLE for some time to perform critical tasks. I need to stop advertising and be disconnected. 
 Let&amp;#39;s consider simple code snippet that runs with the lowest priority: 
 
 Is it possible</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Apr 2018 08:24:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32655/is-race-condition-possible-when-stopping-advertising" /><item><title>RE: Is race condition possible when stopping advertising?</title><link>https://devzone.nordicsemi.com/thread/129492?ContentTypeID=1</link><pubDate>Tue, 24 Apr 2018 08:24:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:234331e6-5f33-414b-a844-b9b1174b370e</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;How about calling&amp;nbsp;sd_ble_gap_adv_stop() no matter what, and then call&amp;nbsp;sd_ble_gap_disconnect() right after? Both sd_ble_gap_adv_stop() and sd_ble_gap_disconnect() just return NRF_ERROR_INVALID_STATE if the advertiser is not running or if the device is not in a connection. That should ensure that your device is not advertising and if a race condition occurred and a peer device connected while the function was executing, it will get disconnected immediately.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is race condition possible when stopping advertising?</title><link>https://devzone.nordicsemi.com/thread/129234?ContentTypeID=1</link><pubDate>Sun, 22 Apr 2018 13:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2024d2b7-29e2-4944-90e6-b70196a8e3a5</guid><dc:creator>Al Bundy</dc:creator><description>&lt;p&gt;S110, SDK v.8&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is race condition possible when stopping advertising?</title><link>https://devzone.nordicsemi.com/thread/127556?ContentTypeID=1</link><pubDate>Tue, 10 Apr 2018 08:33:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6ccbb5a-d8ec-4d90-b8b6-50976333c3ad</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry for the slow response.&lt;/p&gt;
&lt;p&gt;What Softdevice are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>