<?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>How to stop advertising ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15248/how-to-stop-advertising</link><description>Hi, 
 I am testing **ble_app_uart example in the path of
nRF51-SDK\nRF51_SDK_9.0.0_2e23562\examples\ble_peripheral\ble_app_uart\pca10028\s110
\arm5_no_packs\ble_app_uart_s100_pca10028. 
 I want to start and stop advertising manually on a certain condition</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jan 2024 11:26:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15248/how-to-stop-advertising" /><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/463332?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 11:26:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2e1a36-a00e-4350-b8c5-bfceb744c7ee</guid><dc:creator>Marcos Ciancio</dc:creator><description>&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/324154?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 08:25:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d1fd654-590c-46b7-8dad-13db997c8ca2</guid><dc:creator>L.B.</dc:creator><description>&lt;p&gt;Hi guys,&lt;/p&gt;
&lt;p&gt;just wanted to say that our team has found a way to stop the advertising and terminate an active connection by adding:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;init.config.ble_adv_on_disconnect_disabled = true;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in the &amp;quot;static void advertising_init(void)&amp;quot; function (in the ble_app_uart example) and then this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in the place where the stopping has to occur.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using nRF5_SDK_17.0.2_d674dde, and s132, and nrf52832.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps!&lt;/p&gt;
&lt;p&gt;L. B.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/204871?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 22:34:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47f96246-9e94-4a79-bb16-4ad2fe6a4bd3</guid><dc:creator>Vasiliy Baryshnikov</dc:creator><description>&lt;p&gt;In SDK 15, if you are using a template derived project, you should use the following statement with the parameter to stop advertising:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sd_ble_gap_adv_stop(m_advertising.adv_handle);&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/58220?ContentTypeID=1</link><pubDate>Thu, 21 Jul 2016 09:02:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf85b538-d37f-426b-b9ab-24750244c707</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Does it make sense for your application to stop advertising within the ble_nus_data handler? I expect that there won&amp;#39;t be any advertising going on at that point anyway, since the device is already connected.&lt;/p&gt;
&lt;p&gt;SoftDevice API calls run at interrupt priority level 2, this means that you cannot call them from higher priority interrupt, ie. application high, which runs at priority 1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/58219?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 16:50:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:345a7d67-28a7-4187-8c43-544bb88c1c79</guid><dc:creator>shinho</dc:creator><description>&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;As atune answers, sd_ble_gap_adv_stop() works for stopping it.
However sometimes sd_ble_gap_adv_stop() does not works as I intended by other events.&lt;/p&gt;
&lt;p&gt;When put the function in the nus_data_handler(ble_nus_t * p_nus, uint8_t * mbda_data, uint16_t length), it does not work. So I make a flag in the hadler for an condition, and then check the flag in main(){ } and applied sd_ble_gap_adv_stop() as following.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;main {
~~~
  for (;;)
    {
	power_manage();
	
       if (CONN_FLAG == true)
        { 
	     sd_ble_gap_adv_stop();
	}			
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I am not sure whether I am doing right.&lt;/p&gt;
&lt;p&gt;APP_ADV_TIMEOUT_IN_SECONDS is not applicable to my case because stopping period of advertising is not constant. When a correct value is received by NUS Event, advertising should stop. If I can make APP_ADV_TIMEOUT_IN_SECONDS a static variable, it may work. I think.&lt;/p&gt;
&lt;p&gt;If is there better way, please let me know.  Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/58217?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 14:03:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6711f8e7-2273-47cb-8ba7-d539686a13e1</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;Ah yes the timeouts. I&amp;#39;m too used to infinite advertisement and manual control. :) I guess the library isn&amp;#39;t really intended for general use.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/58218?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 13:15:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0f08980-9b4a-4cc7-9085-8f03921695dd</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think the general idea is to let APP_ADV_TIMEOUT_IN_SECONDS decide how long you advertise for, the advertisement is cancelled if the device gets connected to.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to stop advertising ?</title><link>https://devzone.nordicsemi.com/thread/58216?ContentTypeID=1</link><pubDate>Wed, 20 Jul 2016 09:49:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54fbcce2-aad9-43dd-91cc-11e4278e5357</guid><dc:creator>atune</dc:creator><description>&lt;p&gt;I believe you can use a combination of &lt;code&gt;ble_advertising_start(BLE_ADV_MODE_IDLE);&lt;/code&gt; and &lt;code&gt;sd_ble_gap_adv_stop();&lt;/code&gt; to stop the advertisement and keep it stopped. Without the first call the library might restart advertisement on ble/sys events if you have them dispatched. Without the latter call the library won&amp;#39;t stop advertising on its own.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s rather odd that the library doesn&amp;#39;t provide an explicit way to stop advertising. Maybe a bug/lack of a feature or maybe I don&amp;#39;t understand the use case. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>