<?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 advertise when ble are connected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/18937/how-to-stop-advertise-when-ble-are-connected</link><description>hello. 
 I want to toggle ble functions when received message from UART. 
 so when start message come, I start advertising and start services
and stop message come, disconnect(if it connected) and stop advertising. 
 if(stop)
{
 if(m_conn_handle</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Jan 2017 09:11:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/18937/how-to-stop-advertise-when-ble-are-connected" /><item><title>RE: how to Stop advertise when ble are connected</title><link>https://devzone.nordicsemi.com/thread/73205?ContentTypeID=1</link><pubDate>Fri, 13 Jan 2017 09:11:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aafedf94-397d-45c2-937f-5077bf82e241</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;No, it&amp;#39;s not automatically restart advertising. It&amp;#39;s the application code does that, somewhere in the code does, you need to find that. Search for advertising_start() or ble_advertising_start or something similar. Which firmware you are testing with ? Which SDK version ?&lt;/p&gt;
&lt;p&gt;If you try any example in the example\ble_peripheral folder, you can find that the device doesn&amp;#39;t advertise after you get connected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to Stop advertise when ble are connected</title><link>https://devzone.nordicsemi.com/thread/73206?ContentTypeID=1</link><pubDate>Fri, 13 Jan 2017 00:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ba0fa66-535d-4139-949f-e8f7a8e2eba0</guid><dc:creator>hyeongseob</dc:creator><description>&lt;p&gt;Thanks Hung.
but when disconnected softdevice start advertising again.
I want to diable whole ble functions.
when I get a stop message if it connected , I want to disconnect and disable advertising.
but softdevice automatically restart advertising when disconnected.
is there any of options or function to work for this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to Stop advertise when ble are connected</title><link>https://devzone.nordicsemi.com/thread/73204?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2017 11:33:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c738913-503a-4aff-81ac-81ff6ae6c31d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;By default, when you get connected the softdevice automatically disable advertising unless you start it again. You don&amp;#39;t have to stop advertising manually.&lt;/p&gt;
&lt;p&gt;In your code, if it&amp;#39;s connected you should not call advertising_stop() because it&amp;#39;s not advertising.
You should do something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;      if(stop)
{
    if(m_conn_handle != BLE_CONN_HANDLE_INVALID) // ble connected
    {
      sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
    }
   else
   {
       advertising_stop();
   }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>