<?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 DISCONNECT A LINK ON A PERIPHERAL?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2607/how-to-disconnect-a-link-on-a-peripheral</link><description>Hi,
It&amp;#39;s needed to stop the advertisement in my project. I try to stop it directly by using interface sd_ble_gap_adv_stop(), but an error indicating NRF_ERROR_INVALID_STATE occurs if the connection is established. So, I attempt to disconnect first by</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 23 May 2014 01:06:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2607/how-to-disconnect-a-link-on-a-peripheral" /><item><title>RE: HOW TO DISCONNECT A LINK ON A PERIPHERAL?</title><link>https://devzone.nordicsemi.com/thread/10316?ContentTypeID=1</link><pubDate>Fri, 23 May 2014 01:06:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ece3f2ec-10ed-4b85-a7d1-c0a2a7ea7318</guid><dc:creator>Ben.Qin</dc:creator><description>&lt;p&gt;It&amp;#39;s solved. Disconnection is fine as Carles said. Advertisement stop is OK after reinitialiazation. At last, there are no advertisement or connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HOW TO DISCONNECT A LINK ON A PERIPHERAL?</title><link>https://devzone.nordicsemi.com/thread/10315?ContentTypeID=1</link><pubDate>Thu, 22 May 2014 12:02:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0fba8fa-d5fd-40c5-a056-1b1bbabef196</guid><dc:creator>Ben.Qin</dc:creator><description>&lt;p&gt;Hi Carles,
I just want to make a fake sleep mode. Code list below:
void sys_fake_sleeping(void)
{
uint32_t err_code;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;m_advertising_mode = BLE_NO_ADVERTISING;

err_code = sd_ble_gap_disconnect(m_conn_handle,       BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
APP_ERROR_CHECK(err_code);

err_code = sd_ble_gap_adv_stop();
APP_ERROR_CHECK(err_code);
if (NRF_SUCCESS == err_code)
{
	lcd_sleep_in();
	sys_fake_sleep_in();
}  
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;It just called by a button event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: HOW TO DISCONNECT A LINK ON A PERIPHERAL?</title><link>https://devzone.nordicsemi.com/thread/10314?ContentTypeID=1</link><pubDate>Thu, 22 May 2014 11:52:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5f698e-dd59-4828-8487-6e287446fffd</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Advertising will stop automatically when a central connects to you, so there&amp;#39;s no need to call sd_ble_gap_adv_stop().&lt;/p&gt;
&lt;p&gt;On the other hand sd_ble_gap_disconnect() should work fine if you are connected, so I don&amp;#39;t know what&amp;#39;s going on there, can you paste the line where you call that?&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>