<?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>Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102224/dealing-with-data-packet-loss-between-a-peripheral-device-nrf52832-and-a-central-device-nrf52840</link><description>Hi everyone, 
 
 I&amp;#39;m setting up 02 peripheral devices (nRF53832 Dev KIT) that connect to a central device (nRF52840 Dev KIT). In the past few days, I&amp;#39;ve tested its throughput using only 1 peripheral device to send data to the central one at 250 samples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Aug 2023 07:33:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102224/dealing-with-data-packet-loss-between-a-peripheral-device-nrf52832-and-a-central-device-nrf52840" /><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/441767?ContentTypeID=1</link><pubDate>Thu, 17 Aug 2023 07:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e99b9c0f-c305-44f3-afc1-f308ea72bd66</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;How many devices (sensor nodes) are you planning to have in your network here? Since the approximate throughput achievable in the 2MBPS PHY is ~1350kbps (with one device) the throughput with more devices will be considerably lower than this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What&amp;#39;s the requirement of throughput and number of devices in your application exactly?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/441282?ContentTypeID=1</link><pubDate>Tue, 15 Aug 2023 04:38:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11ceeec1-2eb9-4f1e-b2d7-f9147e1b0ac1</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/simonr"&gt;Simonr&lt;/a&gt;&amp;nbsp;Sorry for the late reply. I did try what you suggested, but it didn&amp;#39;t work. I went through the throughput example code and tried to set up some parameters similar in my code. It also didn&amp;#39;t work neither.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding the case you referred above, I got the same issue when a counter variable( BLE_NUS_TX_BUFFER) set on&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE event is always 1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;BLE_NUS_TX_BUFFER -= p_ble_evt-&amp;gt;evt.gatts_evt.params.hvn_tx_complete.count;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The thing is that I&amp;#39;ve never seen any posts regarding BLE multirole - multilink with up to 250 Hz sampling rate. It seems like implementing for low sampling rate is only way to make it work. However, it&amp;#39;ll ruin my specification for this project&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/2639.svg" title="Frowning2"&gt;&amp;#x2639;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/439830?ContentTypeID=1</link><pubDate>Fri, 04 Aug 2023 07:39:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8783dd7e-689b-4496-9236-4fe23815dc9a</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;We also have a&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_att_mtu.html"&gt; throughput example project&lt;/a&gt; for the nRF5 SDK that might be useful to test if you still see the packet loss there as well.&lt;/p&gt;
&lt;p&gt;We suggest using a BLE_GATTS_EVT_HVN_TX_COMPLETE event and count the number of packets you queue to make sure it doesn&amp;#39;t fill up and the transmission is completed successfully. You can check out &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69687/how-to-check-if-the-nus-tx-buffer-is-empty/285841"&gt;this case &lt;/a&gt;where my colleague Einar explains it in detail, as I think you&amp;#39;re missing something like this in your application.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/439594?ContentTypeID=1</link><pubDate>Thu, 03 Aug 2023 05:26:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d42adfe-2a5a-497e-a415-c6072593c284</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;Thank you for your reply, Simon! I&amp;#39;m trying to create a multimodal sensor for bio-signal data collection. These sensors aren&amp;#39;t placed close to each other, so having multiple peripheral devices connected with sensors, and a central hub to transmit all data to a phone app is the main direction right now.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not using&amp;nbsp;Zephyr libraries for this project. For peripheral side, I&amp;#39;m using &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fble_sdk_app_nus_eval.html"&gt;ble_app_uart&lt;/a&gt; example and adding sensor&amp;#39;s code and send data over the air to the central hub. For the central hub, I&amp;#39;m modifying &lt;a href="https://github.com/NordicPlayground/nrf52-ble-app-uart-c-multilink/tree/master"&gt;ble_app_uart_c&lt;/a&gt; example to collect data from peripheral devices and then send these data to the phone app.&lt;/p&gt;
&lt;p&gt;More specifically, the following code snippet shows where I catch data being sent from peripheral devices ( at&amp;nbsp;BLE_NUS_C_EVT_NUS_TX_EVT event). At the same time, I sent these data to the phone app via NUS send function. Is there any situation that sending data to the phone app take too long so that it affects the central device gets data from peripheral ones?&lt;/p&gt;
&lt;p&gt;Please take a look at this short snippet and I would much appreciate if you could recommend if there is another way to handle data coming from peripheral devices and also sending these data to the phone app. Thanks!&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void ble_nus_c_evt_handler(ble_nus_c_t * p_ble_nus_c, ble_nus_c_evt_t const * p_ble_nus_evt)
{
    ret_code_t err_code;

    switch (p_ble_nus_evt-&amp;gt;evt_type)
    {
        case BLE_NUS_C_EVT_DISCOVERY_COMPLETE:
            NRF_LOG_INFO(&amp;quot;Discovery complete.&amp;quot;);
            err_code = ble_nus_c_handles_assign(p_ble_nus_c, p_ble_nus_evt-&amp;gt;conn_handle, &amp;amp;p_ble_nus_evt-&amp;gt;handles);
            APP_ERROR_CHECK(err_code);

            err_code = ble_nus_c_tx_notif_enable(p_ble_nus_c);
            APP_ERROR_CHECK(err_code);
            NRF_LOG_INFO(&amp;quot;Connected to device with Nordic UART Service.&amp;quot;);
            break;

        case BLE_NUS_C_EVT_NUS_TX_EVT:
            //ble_nus_chars_received_uart_print(p_ble_nus_evt-&amp;gt;p_data, p_ble_nus_evt-&amp;gt;data_len);
            // receive data from peripheral devices
            // then transmit it to a phone app using - err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
            break;

        case BLE_NUS_C_EVT_DISCONNECTED:
            NRF_LOG_INFO(&amp;quot;Disconnected.&amp;quot;);
            scan_start();
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/439473?ContentTypeID=1</link><pubDate>Wed, 02 Aug 2023 11:17:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a65ab27c-f318-4e13-8b43-a07ecf0b925b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thank you for the update. What application exactly is your nRF peripheral and central projects based on? Could you try with the throughput sample and see if you have the same issue there?&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/throughput/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/throughput/README.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re just using a modified version of the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_uart/README.html"&gt;Peripheral &lt;/a&gt;and &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/central_uart/README.html"&gt;Central UART &lt;/a&gt;applications it could be that a buffer is filling up either on the transmitting or receiving side if you&amp;#39;re transmitting over BLE faster than the UART buffer can handle the messages for example.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/439138?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2023 23:07:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a3f3140-00de-415e-8f71-7dfc82a6e03f</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;So you agreed with Hugh&amp;#39;s assumption about the data loss which is caused by a disconnect-connect event happening between peripheral device and central device?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did add a counter to check if that issue happened. However, there was no disconnect-connect events like what Hugh described.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I played with DLE, ATT-MTU and used 2M PHY to avoid data loss. However, data loss still happens.&lt;/p&gt;
&lt;p&gt;Just wanna make sure you got my point, here is a brief diagram of my system: Data from peripheral devices are sent to nRF52840 with central role. The nRF52840 with peripheral role then sent data to a phone app.&lt;/p&gt;
&lt;p&gt;Peripheral devices (nRF52832) ----(send data)----&amp;gt; nRF52840 (Central role) ----(Peripheral role) -----(send data)---&amp;gt; a phone app.&lt;/p&gt;
&lt;p&gt;Here is a short video showing how data are collected from a phone app. As you can see, the first graph (index) is showing number of packets being sent from nRF52840 with peripheral role. It wasn&amp;#39;t smooth, meaning data loss is happening.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My question is that did data loss happen from the p&lt;span&gt;eripheral devices (nRF52832)&amp;nbsp;sending data to&amp;nbsp;nRF52840) or from nRF52840 sending data to the phone app? Thanks!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Packets-loss.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/438906?ContentTypeID=1</link><pubDate>Mon, 31 Jul 2023 07:47:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54ca606d-2b19-4546-b4b7-2b283b832679</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I deemed Hugh&amp;#39;s reply to this case as sufficient, so I did not see the need to add another reply here. I agree that you should add a handler like the ble_evt_handler() snippet, and use &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/100276/dropped-packets-with-bt_nus_send"&gt;this case&lt;/a&gt; for more info on the matter. Let me know if you have any specific follow-up questions that aren&amp;#39;t answered in the other case.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/438816?ContentTypeID=1</link><pubDate>Fri, 28 Jul 2023 17:17:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8739d268-5236-454a-9bed-1c9b2ae70449</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;I saw a notification saying an engineer was assigned to this question. I&amp;#39;m wondering if anyone will take a look at my issue soon? It has been for 3 days now. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/438376?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2023 17:43:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4be16fbc-8cf0-470c-b392-3a9a2164a6b5</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;Thank you for the suggestion! I&amp;#39;ll check it out and let you know.&lt;/p&gt;
&lt;p&gt;Btw, you mentioned adding a handler, could you elaborate more on this?&lt;/p&gt;
&lt;p&gt;Tai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/438215?ContentTypeID=1</link><pubDate>Wed, 26 Jul 2023 10:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a589325-85ea-4f91-9f99-347b337c4fd5</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;It is likely there is a disconnect-connect event using the nRF52840 (which has a poor antenna compared to the Android phone) which will cause loss of a packet unless you add a handler to work around the issues caused by such an event. To prove this add a counter which increments on each BLE disconnect and compare with the packet loss counter; force a few disconnects on the Android by walking away. For a more in-depth discussion see&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/100276/dropped-packets-with-bt_nus_send"&gt;dropped-packets-with-bt_nus_send&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            ...
            // Indicate number of connections for checking against missing packets
            mBleConnectionCounter++;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dealing with data packet loss between a peripheral device (nRF52832) and a central device (nRF52840)</title><link>https://devzone.nordicsemi.com/thread/438133?ContentTypeID=1</link><pubDate>Tue, 25 Jul 2023 18:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ab105f0-036d-4a0e-9f6a-3e33a37e3744</guid><dc:creator>Tai</dc:creator><description>&lt;p&gt;I forgot to mention that if I use an Android phone as a central. Data packet loss never happens.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regarding the event BLE_NUS_EVT_TX_RDY, I put a counter in the following code to see if it is triggered linearly or not and I was able to receive a counter with increment by 1. It means, whenever 16-byte data packet was successfully transmitted, the counter in that event increased by 1. I&amp;#39;m wondering if any setup I need to to notice from the central side?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:104px;max-width:451px;" height="104" src="https://devzone.nordicsemi.com/resized-image/__size/902x208/__key/communityserver-discussions-components-files/4/pastedimage1690310677096v2.png" width="451" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for handling the data from the Nordic UART Service.
 *
 * @details This function will process the data received from the Nordic UART BLE Service and send
 *          it to the UART module.
 *
 * @param[in] p_evt       Nordic UART Service event.
 */
/**@snippet [Handling the data received over BLE] */
static void nus_data_handler(ble_nus_evt_t * p_evt)
{

    uint32_t err_code;

    switch(p_evt-&amp;gt;type)
    {
	case BLE_NUS_EVT_RX_DATA:

          NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
          NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);

          for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
          {
              do
              {
                  err_code = app_uart_put(p_evt-&amp;gt;params.rx_data.p_data[i]);
                  if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
                  {
                      NRF_LOG_ERROR(&amp;quot;Failed receiving NUS message. Error 0x%x. &amp;quot;, err_code);
                      APP_ERROR_CHECK(err_code);
                  }
              } while (err_code == NRF_ERROR_BUSY);
          }
          if (p_evt-&amp;gt;params.rx_data.p_data[p_evt-&amp;gt;params.rx_data.length - 1] == &amp;#39;\r&amp;#39;)
          {
              while (app_uart_put(&amp;#39;\n&amp;#39;) == NRF_ERROR_BUSY);
          }
	  break;
	case BLE_NUS_EVT_TX_RDY: //  check if Service is ready to accept new data to be transmitted.
	  
	  is_transmitted = true;
	  index ++;
	  NRF_LOG_INFO(&amp;quot;Is data transmmitted: %d\r\n&amp;quot;, index);
	  break;

	default:
	  
	  break;
    }

}
/**@snippet [Handling the data receive&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>