<?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>Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96419/peripheral-is-not-able-to-disconnect-connection-with-peer</link><description>Hey, 
 In the code below bt_conn_disconnect function is executed but the connection is still there. My goal is that peripheral is able to disconnect the connected device if there is no data received after a certain time. 
 Code is here 
 
 
 Thanks in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 17 Feb 2023 12:56:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96419/peripheral-is-not-able-to-disconnect-connection-with-peer" /><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/410644?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 12:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18992fb7-b15e-4648-8313-7b32cfdef16f</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Happy to hear.&lt;/p&gt;
&lt;p&gt;If you have any further questions you are welcome to post a new ticket. I&amp;#39;ll close this one.&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/410609?ContentTypeID=1</link><pubDate>Fri, 17 Feb 2023 11:36:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f39453a-59be-4b6a-bfd6-f8206eb67b7c</guid><dc:creator>Mustafa</dc:creator><description>&lt;p&gt;Thanks it works!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/410485?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 22:50:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb894ef1-2a79-4a9d-b0c7-0cf5d33fe26c</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Sorry about the delayed response.&lt;/p&gt;
&lt;p&gt;The reason it fails is probably the disconnect reason. BT_HCI_ERR_CONN_TIMEOUT is not acceptable as a disconnect reason.&lt;/p&gt;
&lt;p&gt;Try using BT_HCI_ERR_REMOTE_USER_TERM_CONN instead.&lt;/p&gt;
&lt;p&gt;More information here: &lt;br /&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/connectivity/bluetooth/api/connection_mgmt.html#c.bt_conn_disconnect"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/connectivity/bluetooth/api/connection_mgmt.html#c.bt_conn_disconnect&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/409050?ContentTypeID=1</link><pubDate>Thu, 09 Feb 2023 06:48:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89577f9a-0ebc-44b6-9a60-d75ba3cdffcb</guid><dc:creator>Mustafa</dc:creator><description>&lt;p&gt;Hey &lt;span&gt;Joakim&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Actually, I mean this call&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void connection_thread_fn(void) {
	k_sem_init(&amp;amp;ble.conn_timeout_sema, 0, 1);
	for (;;) {
		if (k_sem_take(&amp;amp;ble.conn_timeout_sema, K_FOREVER) == 0) {
			LOG_DBG(&amp;quot;Start to disconnect the device&amp;quot;);
			if (ble.current_conn != NULL) {
				bt_conn_disconnect(ble.current_conn, BT_HCI_ERR_CONN_TIMEOUT);
			}
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/408988?ContentTypeID=1</link><pubDate>Wed, 08 Feb 2023 19:30:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6f2d7e4-73b8-477f-8a2f-ca812ff50640</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Looking at your code; Which call to &lt;span&gt;&lt;strong&gt;bt_conn_disconnect&lt;/strong&gt; are you referring to?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Br, &lt;br /&gt;Joakim&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/408521?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 11:43:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ca04e35-9824-482c-bd80-90333b82d16e</guid><dc:creator>Mustafa</dc:creator><description>&lt;p&gt;Thanks&amp;nbsp;&lt;span&gt;Joakim,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;the connection is never terminated after executing the function&amp;nbsp;&lt;strong&gt;bt_conn_disconnect&lt;/strong&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/408511?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 11:18:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7891eef0-1b3e-4e3e-b1a9-fdb9b340450e</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll take a look at your code.&amp;nbsp;&lt;/p&gt;
[quote user=""]In the code below &lt;strong&gt;bt_conn_disconnect&lt;/strong&gt; function is executed but the connection is still there.[/quote]
&lt;p&gt;Is the connection never terminated or is the problem that the device instantly reconnects to the device after calling bt_conn_disconnect()?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/408508?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 11:13:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:378375a4-3bb8-4261-9a16-dfc6699de42b</guid><dc:creator>Mustafa</dc:creator><description>&lt;p&gt;sure!&lt;/p&gt;
&lt;p&gt;sdk connect: v2.2&lt;/p&gt;
&lt;p&gt;dk: nrf5340dk&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral is not able to disconnect connection with peer.</title><link>https://devzone.nordicsemi.com/thread/408507?ContentTypeID=1</link><pubDate>Tue, 07 Feb 2023 11:11:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb95c30b-cabf-4311-a6d4-8ff53ee8ab25</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for your question.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you please add which version of the SDK you are working with?&lt;/p&gt;
&lt;p&gt;Br,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>