<?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>nrf51822 ble UART Random disconnection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16365/nrf51822-ble-uart-random-disconnection</link><description>Hello all! 
 Sorry for what might seems an obvious question, my skills are what they are :-).
We have a small circuit based on nrf51822 chip. 
 Our software is currently working fine but we are doing several tests to make sure some unprobable events</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Sep 2016 06:42:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16365/nrf51822-ble-uart-random-disconnection" /><item><title>RE: nrf51822 ble UART Random disconnection</title><link>https://devzone.nordicsemi.com/thread/62624?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 06:42:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6dfacf8-7dee-4c14-8b20-ddf72b7ba6c0</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Are you perhaps calling the ble_nus_buffer_send function from an interrupt context? If that is the case, it will block any softdevice callbacks, including the BLE_GAP_EVT_DISCONNECTED. The solution is to execute the ble_nus_buffer_send in main context, which enables any BLE callback to interrupt the wait in the ble_nus_buffer_send function. See the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s130.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=3_6_2_0_15_1"&gt;priority scheme here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 ble UART Random disconnection</title><link>https://devzone.nordicsemi.com/thread/62623?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 22:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fa14ed4-4d51-49c7-9b9c-f23939dd3e9a</guid><dc:creator>Francois</dc:creator><description>&lt;p&gt;Indeed, it could be the case. We are getting closer to a solution :-)&lt;/p&gt;
&lt;p&gt;However when the connection is &amp;quot;brutal&amp;quot; and a TX is happening, &amp;quot;BLE_GAP_EVT_DISCONNECTED&amp;quot; is never reached... I could put &amp;quot;BtDataTxComplete == 1&amp;quot; there and exit the loop...&lt;/p&gt;
&lt;p&gt;Would &amp;quot;BLE_GAP_EVT_TIMEOUT&amp;quot; happen in case of brutal disconnection?&lt;/p&gt;
&lt;p&gt;See&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;switch (p_ble_evt-&amp;gt;header.evt_id)
   {
    case BLE_GAP_EVT_CONNECTED:
        //err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
        //APP_ERROR_CHECK(err_code);
        LED_On();
        m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
        break;
        
    case BLE_GAP_EVT_DISCONNECTED:
        //err_code = bsp_indication_set(BSP_INDICATE_IDLE);
        //APP_ERROR_CHECK(err_code);
        LED_Off();
        isInPushMode = 0;
        m_conn_handle = BLE_CONN_HANDLE_INVALID;
        BtCommandWasReceived = COMMAND_EMPTY;
        break;

   case BLE_GAP_EVT_TIMEOUT:
 ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 ble UART Random disconnection</title><link>https://devzone.nordicsemi.com/thread/62622?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 16:05:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95b43f3a-06a0-46df-9798-8657ee733f51</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Francois&lt;/p&gt;
&lt;p&gt;Correct me if I am wrong, but does your BtDataTxComplete flag check for the BLE_EVT_TX_COMPLETE event flag? If so, I can see this as normal behavior that your code waits in the &lt;code&gt;while(BtDataTxComplete == 0) {};&lt;/code&gt; loop if you have sent the BLE packet to the softdevice with &lt;code&gt;ble_nus_string_send&lt;/code&gt; and have not received a BLE_EVT_TX_COMPLETE from the softdevice, which means that the packet has been sent.    Then the packet is just waiting in a softdevice buffer and waiting to be sent. When you connect again with your phone, the packet is sent, which triggers a BLE_EVT_TX_COMPLETE event and the code continues execution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 ble UART Random disconnection</title><link>https://devzone.nordicsemi.com/thread/62621?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 22:18:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:803e1dff-741f-49c7-b840-a06255813790</guid><dc:creator>RichieJH</dc:creator><description>&lt;p&gt;We often see selecting disconnect in an Android app doesn&amp;#39;t guarantee the Android will actually disconnect.  So the nRF will think it is still in a connection.  In Wireshark the stream of bits that keep the connection alive are originating from the Android phone so it appears to be a problem on the Android side.  We now ensure disconnection from nRF side if this happens.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>