<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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 missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/85722/peripheral-missing-disconnect-on-timeout</link><description>When communication fails on NRF connectivity dongle (In Python via pc_ble_driver) and Error code: NRF_ERROR_BUSY is received on attempts to write and one restarts python script, a timeout appears to occur in peripheral. the connection changes state (after</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Mon, 16 May 2022 12:33:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/85722/peripheral-missing-disconnect-on-timeout" /><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/368047?ContentTypeID=1</link><pubDate>Mon, 16 May 2022 12:33:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c71e43a9-b11e-43bd-b1de-694f379a1fb4</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;I have not yet managed to grab a sniff, but I did discover some issue related to this.&lt;br /&gt;The code uses NUS and so there is a callback registered with NUS for send, and as we allocate buffers and deliver to NUS we are not able to free them as link goes down.&lt;/p&gt;
&lt;p&gt;bt_gatt_notify_cb() is called by NUS in&amp;nbsp;bt_nus_send() and it gives it (in param structure) a single callback for when it is complete. As long as link is alive when it starts this function, it does not fail, and queues up the data. However, there is no callback for failure if link goes down and there is now nobody to deliver the tx events to. Next connection is established, but nothing can be sent, and when this new connection times out (4 seconds default is a long time) nothing happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/364691?ContentTypeID=1</link><pubDate>Mon, 25 Apr 2022 11:31:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:402aa374-3b5d-43b5-a630-1eddb463d2ce</guid><dc:creator>user15146</dc:creator><description>[quote user="Kyrre Aalerud"]When reset later it sometimes gets the peripheral in an odd state where it doesn&amp;#39;t disconnect properly?[/quote]
&lt;p&gt;Maybe a Bluetooth sniffer trace of the issue could help give some clues about what is needed to trigger this issue. See:&amp;nbsp;&lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a long shot, but maybe the fix in this PR could help:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/44194"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/44194&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/364418?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 09:34:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc62714f-9650-4cc0-a6b0-036ba4514f42</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;So far it has been difficult to strip it down to a working example.&lt;br /&gt;The basic premise is apparently starting new connections while already starting a connection from the python side in such a way as to get the dongle in a &amp;quot;busy&amp;quot; state. When reset later it sometimes gets the peripheral in an odd state where it doesn&amp;#39;t disconnect properly?&lt;/p&gt;
&lt;p&gt;Maybe we can share project access, but it would be some work to make it run without the external hardware that is integrated into the code. In theory a blank NUS example with some high traffic should be all it takes while trying to &amp;quot;pester&amp;quot; it with connections, but the sample does not build for me and I did not have time to dig into it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/364402?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 08:50:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f04c7c2-3bc0-47cc-ab2d-5a994615be55</guid><dc:creator>user15146</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have tried to reproduce the issue,&amp;nbsp;but so far it&amp;#39;s working fine here.&lt;/p&gt;
&lt;p&gt;Are you able to&amp;nbsp;provide a simple pc-ble-driver python script, together with a simple nRF Connect SDK sample that reproduces this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/364393?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2022 08:17:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76b7d192-f5b9-4678-bf80-f42de507e0f2</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;Has there been any progress on this? We manage to reproduce the hang regularly but are unable to figure out why it happens. Any failed transmit on NUS is handled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/358603?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 10:54:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e20da26-e50c-445d-b178-737f6b666e60</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;We only support one connection, and it appears the issue happens more if we trigger two quick connects from same unit in python with connectivity dongle before previous connect has finished or failed. This seems to queue up two connections in such a way as to leave us out of sync and closing/reopening python sript (and device) seems to cause the connection to close so we can continue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/358602?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 10:52:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78ae6de8-1919-4d18-b352-37fe5ef88d24</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;The ref:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void connected(struct bt_conn *conn, uint8_t err)
{
    struct bt_conn_info info;

    if (err) 
    {
        LOG_ERR(&amp;quot;BLE Connection failed (err 0x%02x)&amp;quot;, err);
        return;
    }

    default_conn_ble = bt_conn_ref(conn);

    bt_conn_get_info(conn, &amp;amp;info);
    LOG_INF(&amp;quot;BLE Connected: Interval=%d, Datalen=%d&amp;quot;, info.le.interval, info.le.data_len-&amp;gt;tx_max_len);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The connected() callback goes on to check some parameters and request changes in data length if appropriate.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The unref:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void disconnected(struct bt_conn *conn, uint8_t reason)
{
    LOG_WRN(&amp;quot;BLE Disconnected (reason 0x%02x)&amp;quot;, reason);
    if (auth_conn) 
    {
        bt_conn_unref(auth_conn);
        auth_conn = NULL;
    }
    
    if (default_conn_ble) 
    {
        bt_conn_unref(default_conn_ble);
        default_conn_ble = NULL;
        disable_reporting_over_ble(); // Once disconnected, disable reporting over BLE
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/358586?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 10:06:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1dd78c6-4ce8-40ea-93a0-584a62ec64e8</guid><dc:creator>user15146</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Kyrre Aalerud"]when the error happens, ref is still 3.&lt;br /&gt;Normally ref is 2,[/quote]
&lt;p&gt;That sounds strange. Where are the places you call&amp;nbsp;&lt;span&gt;bt_conn_ref() and&amp;nbsp;bt_conn_unref() ? In what callbacks?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you post the code relevant functions / callbacks where you call&amp;nbsp;bt_conn_ref/bt_conn_unref ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/357670?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 13:11:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0487c038-4a01-43b8-897f-2f84aeb404e1</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;Looks like, when the error happens, ref is still 3.&lt;br /&gt;Normally ref is 2, and upon disconnect we unref the local pointer to the connection and it returns to 1, and&amp;nbsp;advertising is resumed. Are we using the&amp;nbsp;bt_conn_ref() correctly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/357647?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 12:19:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c44b62e5-254d-4edf-8b01-da724f2974b1</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;When debugging I notice that disconnect does not work as it returns that it is not connected, but conn-&amp;gt;ref is not 0. Calling unref till it reaches 0 causes it to start advertising again.&lt;/p&gt;
&lt;p&gt;But upon trying to connect to this we get &lt;br /&gt;***New connection: 0 (printed by&amp;nbsp;on_gap_evt_connected in our script)&lt;br /&gt;connect_to_device error: &amp;#39;NoneType&amp;#39; object is not subscriptable.&lt;/p&gt;
&lt;p&gt;After this, it stops advertising again while state remains in BT_CONN_CONNECT_ADV.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/357642?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 12:08:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d4cfc2e-f58d-46d6-9ed8-f2d3120e8ba8</guid><dc:creator>user93592</dc:creator><description>&lt;p&gt;Yes, and it works normally most of the time.&lt;/p&gt;
&lt;p&gt;Once in a while we get this odd situation where something happens after a while and the connection changes state. Then it no longer advertises, and link is no longer up. Trying to call on disconnect has no effect, and trying to start advertising returns 0 while not starting advertising.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peripheral missing disconnect on timeout</title><link>https://test-devzone.nordicsemi.com/thread/357636?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 12:00:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:791d1aa9-c85f-49a8-8fdd-f3e4bf81f71d</guid><dc:creator>user15146</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Did you register a disconnected callback? E.g. as shown &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.8.0/samples/bluetooth/peripheral_uart/src/main.c#L379"&gt;here&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>