<?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>Prevent BLE connection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55251/prevent-ble-connection</link><description>I&amp;#39;m having a advertising device and then I want to stop advertising and prevent BLE connection from device that would have received the advertisement. It seems to work by using this: 
 err_code = sd_ble_gap_adv_stop(m_advertising.adv_handle); nrf_sdh_disable_request</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Dec 2019 13:38:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55251/prevent-ble-connection" /><item><title>RE: Prevent BLE connection</title><link>https://devzone.nordicsemi.com/thread/224200?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 13:38:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36116f33-58d2-4dc1-9452-e9f41d754805</guid><dc:creator>Frederic</dc:creator><description>&lt;p&gt;ok I will do this. I though there were a easy was to prevent connection in the Softdevice in such situation but I will follow your advice and disconnect the remote device in the&amp;nbsp;BLE_GAP_EVT_CONNECTED event.&lt;/p&gt;
&lt;p&gt;Tahnk a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prevent BLE connection</title><link>https://devzone.nordicsemi.com/thread/224196?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2019 13:35:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1016e5b-9634-4db2-a19d-71b563dde766</guid><dc:creator>Sigurd</dc:creator><description>[quote user="FredT"]prevent Bluetooth connection from device which had received the advertisement before I stop advertising[/quote]
&lt;p&gt;&amp;nbsp;If a device connects in this time window, then maybe you could instead try to set a flag/variable, and when this flag is set to true, you will on the&amp;nbsp;BLE_GAP_EVT_CONNECTED event have a if-test that could disconnect the device if it connected ?&lt;/p&gt;
&lt;p&gt;Snippet:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;.
.
.
case BLE_GAP_EVT_CONNECTED:
    if(prevent_connection)
    {
        err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
        APP_ERROR_CHECK(err_code);
    }
.
.
.
.
.
.

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prevent BLE connection</title><link>https://devzone.nordicsemi.com/thread/223948?ContentTypeID=1</link><pubDate>Thu, 05 Dec 2019 14:16:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07595134-be01-48eb-8ed7-8613d7fc2a61</guid><dc:creator>Frederic</dc:creator><description>&lt;p&gt;I called&amp;nbsp;&lt;span&gt;nrf_sdh_disable_request() to disable the Softdevice and prevent Bluetooth connection from device which had received the advertisement before I stop advertising. Since I want to prevent Bluetooth connection as well it seems that&amp;nbsp;nrf_sdh_disable_request() service this purpose.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The first issue is to prevent Bluetooth connection from device that have advertisement data.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Prevent BLE connection</title><link>https://devzone.nordicsemi.com/thread/223922?ContentTypeID=1</link><pubDate>Thu, 05 Dec 2019 13:34:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:315a1147-8193-4d49-9225-0ce8d7cc460e</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Why did you call&amp;nbsp;&lt;span&gt;nrf_sdh_disable_request() ?&amp;nbsp;sd_ble_gap_adv_stop() should be enough to stop the advertising.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If you are using&amp;nbsp;nrf_sdh_disable_request/nrf_sdh_disable_request, you might need to call&amp;nbsp;advertising_init() again.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>