<?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>Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/10823/avoid-advertising-after-disconnect</link><description>Hi, 
 I use NRF51DK with SD11 and SDK 9. I started with the ble_peripheral_uart template.
I would like to manually disconnect from central (an iOS platform) and not advertise again after disconnection (The program will enable advertising again later</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 24 Sep 2023 22:14:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/10823/avoid-advertising-after-disconnect" /><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/447320?ContentTypeID=1</link><pubDate>Sun, 24 Sep 2023 22:14:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e1697ff-91e3-48ad-a517-c55550113eac</guid><dc:creator>fproko</dc:creator><description>&lt;p&gt;Right, I think this is the best way! In function&amp;nbsp;&lt;em&gt;advertising_init()&lt;/em&gt; just add the line:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;em&gt;init.config.ble_adv_on_disconnect_disabled = true;&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/273797?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 14:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ba40680-8941-4a7e-a4e4-291d900c7dbf</guid><dc:creator>hdadhich</dc:creator><description>&lt;p&gt;Please check if you have init.config.&lt;strong&gt;ble_adv_on_disconnect_disabled&lt;/strong&gt; = true in &lt;strong&gt;advertising_init&lt;/strong&gt;() funciton. If you wish not to advertise after disconnection make it &amp;quot;true&amp;quot; else &amp;quot;false&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/40465?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 08:46:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34e2ee0f-2a7f-425a-a8a9-2f5bcb7af114</guid><dc:creator>Jeong Hyun Seok</dc:creator><description>&lt;p&gt;Nice code.
Thanks a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/40461?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2015 15:07:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53cb0b5f-26b5-40a3-a621-2b4d9da0b053</guid><dc:creator>Arnaud Nelissen</dc:creator><description>&lt;p&gt;Thanks Hung, I could only try the solution today. It worked perfectly.&lt;/p&gt;
&lt;p&gt;Thanks both of you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/40464?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2015 15:06:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c14f3c51-b0be-4a63-834d-849f79ef1641</guid><dc:creator>Arnaud Nelissen</dc:creator><description>&lt;p&gt;Your solution worked perfectly, thanks a lot monpetit !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/40462?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2015 10:12:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4266661-aaf2-45f7-b4a8-165314294793</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Arnaud,
As Monpetit mentioned, the code that start the advertising again is at BLE_GAP_EVT_DISCONNECTED event in ble_advertising_on_ble_evt() in ble_advertising.c
If the answer is correct, please mark it as accepted answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Avoid advertising after disconnect</title><link>https://devzone.nordicsemi.com/thread/40463?ContentTypeID=1</link><pubDate>Sat, 12 Dec 2015 02:32:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab62c763-1fde-4c70-bbf3-127a5f9ceb7f</guid><dc:creator>monpetit</dc:creator><description>&lt;p&gt;How about modifying the &lt;code&gt;ble_advertising.c&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;your code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bool manually_disconnected  = false;

...

manually_disconnected = true;
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); // Disconnect from BLE device
APP_ERROR_CHECK(err_code);
sd_ble_gap_adv_stop();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ble_advertising.c:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;extern bool manual_diconnect;

void ble_advertising_on_ble_evt(ble_evt_t const * p_ble_evt)
{
    static uint16_t current_slave_link_conn_handle = BLE_CONN_HANDLE_INVALID;

    switch (p_ble_evt-&amp;gt;header.evt_id) {
        ...

    // Upon disconnection, whitelist will be activated and direct advertising is started.
    case BLE_GAP_EVT_DISCONNECTED: {
        uint32_t err_code;
        m_whitelist_temporarily_disabled = false;

        if (!manually_disconnected) {
            if (p_ble_evt-&amp;gt;evt.gap_evt.conn_handle == current_slave_link_conn_handle) {
                err_code = ble_advertising_start(BLE_ADV_MODE_DIRECTED);
                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (m_error_handler != NULL)) {
                    m_error_handler(err_code);
                }
            }
        }
        break;
    }
        ...
    }
    ...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Good luck to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>