<?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>I want to stop being auto-registered.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98291/i-want-to-stop-being-auto-registered</link><description>Dear. all 
 In the BLE APP UART example of the peripheral, we are going to modify the part that is automatically registered. 
 Operation is when KEY1 is pressed, 
 In the basic example, Advertising is automatically restarted and registered again. 
 I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 31 Mar 2023 08:14:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98291/i-want-to-stop-being-auto-registered" /><item><title>RE: I want to stop being auto-registered.</title><link>https://devzone.nordicsemi.com/thread/418506?ContentTypeID=1</link><pubDate>Fri, 31 Mar 2023 08:14:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd6c9648-e626-45aa-92e2-5e2093fab676</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi pkr2258,&lt;/p&gt;
&lt;p&gt;This depends on whether or not your code is using the Advertising Module or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are using the advertising module, you need to configure it to not restart advertisement upon disconnection. It can be done at the initialization of the module. Please look into &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/structble__advertising__init__t.html#a608be739421d5c94df234f35a035eb73"&gt;the config field&lt;/a&gt; and its sub-field in &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/structble__advertising__init__t.html"&gt;the ble_advertising_init_t structure&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you are not using the advertising module, the restart of the advertisement should be around the handling of the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_p___e_n_u_m_e_r_a_t_i_o_n_s.html#gada486dd3c0cce897b23a887bed284fef"&gt;BLE_GAP_EVT_DISCONNECTED&lt;/a&gt;&amp;nbsp;event.&lt;/p&gt;
&lt;p&gt;Regarding your code, I don&amp;#39;t think advertising has started by the point you called&amp;nbsp;sd_ble_gap_adv_stop().&amp;nbsp;The restart of advertising does not happen until the&amp;nbsp;&lt;span&gt;BLE_GAP_EVT_DISCONNECTED&amp;nbsp;event (the Advertising Module also does it that way).&amp;nbsp;Right after&amp;nbsp;sd_ble_gap_disconnect(), this event doesn&amp;#39;t happen yet, thus advertising is not running yet, and &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_p___f_u_n_c_t_i_o_n_s.html#ga732faeeb8489dcb34873d78e773957bc"&gt;so sd_ble_gap_adv_stop() will just fail with&amp;nbsp;NRF_ERROR_INVALID_STATE&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope my explanation makes sense. Please let me know if anything is still unclear or if you have any further questions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hieu&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>