<?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>NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89278/nrf52840-ble-nus-data-transmission-is-too-slow</link><description>Dear all, my project consists of 6 nRF52840 custom boards, one acting as central device and the other five acting as peripherals (star connection). 
 The central device receives USB serial commands from PC and transmits them via BLE to the five peripherals</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 28 Jun 2022 10:39:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89278/nrf52840-ble-nus-data-transmission-is-too-slow" /><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374499?ContentTypeID=1</link><pubDate>Tue, 28 Jun 2022 10:39:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d821451-317c-4245-915f-2a99efe001fd</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi, I finally fixed it... The solution is the following modification&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;size = 243;
for(uint8_t i = 0; i&amp;lt;16; i++)
{
 do{
    nrf_gpio_pin_clear(UART_RX_PIN); // TODO TEST OUTPUT
    err_code = ble_nus_data_send(m_nus_gen, &amp;amp;localBuffer.convPacket[i*size], &amp;amp;size, *m_conn_handle_gen);
    nrf_gpio_pin_set(UART_RX_PIN); // TODO TEST OUTPUT
 }while(err_code == NRF_ERROR_RESOURCES); //while(i &amp;lt;= 16);
}
bleBuffer_is_full = true; 
while(bleBuffer_is_full); &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I used to check the&amp;nbsp;bleBuffer_is_full flag after every packet transmission and this was slowing down the whole transmission process. Now I check it only once at the end of the transmission and the speed has increased to 82kBps. &lt;br /&gt;I assume that by changing the connection interval and event length values it will reach 90kBps.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374337?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 11:47:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adc95ebf-eef7-48a6-9369-b13e630ca2db</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi, currently I have only one DK so sniffer is not an option at the moment. &lt;br /&gt;But I have found what is causing the issue and I don&amp;#39;t know how to solve it.&lt;/p&gt;
&lt;p&gt;In the code part that corresponds to the 4096 bytes transmission from the peripheral to the central, I check for NRF_resources error after each packet transmission and I block the code there in that case until a BLE buffer is free and BLE_GATTS_EVT_HVN_TX_COMPLETE event occurs. &lt;br /&gt;&lt;br /&gt;The time for one packet transmission, with&amp;nbsp;ble_nus_data_send(), is approximately 200usec&amp;nbsp; and the time between two consecutive transmissions is approximately 25 msec. The whole problem lies in those 25msec.&lt;br /&gt; Is there a way to reduce it?&lt;br /&gt;&lt;br /&gt;If I entirely remove the NRF_resources error check&amp;nbsp; and I transmit data continuously the peripheral device crashes. &lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; size = 243;
       for(uint8_t i = 0; i&amp;lt;16; i++)    //send the cache buffer to tablet in chunks of 128 bytes
       {  
          nrf_gpio_pin_clear(TestPin); 
          err_code = ble_nus_data_send(m_nus_gen, &amp;amp;localBuffer.convPacket[i*size], &amp;amp;size, *m_conn_handle_gen);
          if(err_code = NRF_ERROR_RESOURCES)
          {
             bleBuffer_is_full = true; 
             while(bleBuffer_is_full); 
          }
          nrf_gpio_pin_set(UART_RX_PIN); // TODO TEST OUTPUT
       }
       size = 191;
       err_code = ble_nus_data_send(m_nus_gen, &amp;amp;localBuffer.convPacket[16*size], &amp;amp;size, *m_conn_handle_gen);
       if(err_code = NRF_ERROR_RESOURCES)
       {
          bleBuffer_is_full = true; 
          while(bleBuffer_is_full); 
       }     
       nrf_gpio_pin_set(TestPin); &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374305?ContentTypeID=1</link><pubDate>Mon, 27 Jun 2022 09:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72e03607-fc2f-4485-a8fa-83bba013bd50</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH is set a bit low, have you tried increasing it? Could you use &lt;a href="https://www.nordicsemi.com/Products/Development-tools/nRF-Sniffer-for-Bluetooth-LE"&gt;nRF Sniffer&lt;/a&gt;&amp;nbsp;and provide the sniffer trace when you send data with your original connection parameters?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374186?ContentTypeID=1</link><pubDate>Fri, 24 Jun 2022 13:55:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a811b810-5a1a-4681-9971-914904314e16</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Hi, no this does not work. In fact it makes the transmission much slower (1.7kB/sec).&lt;br /&gt;With the previous settings the transmission reached 17kB/sec. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374172?ContentTypeID=1</link><pubDate>Fri, 24 Jun 2022 13:25:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79b63463-5f73-43fb-a299-2f1d0707088e</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Maybe you can try to set the connection parameters as in the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_att_mtu.html?cp=8_1_4_2_1_0"&gt;throughput &lt;/a&gt;example?:&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/pastedimage1656077098272v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE NUS data transmission is too slow</title><link>https://devzone.nordicsemi.com/thread/374111?ContentTypeID=1</link><pubDate>Fri, 24 Jun 2022 10:33:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23296467-cd39-480f-8121-18b5a74b00e1</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;I think I have found the root cause. The time between two packet transfers takes about 25msec. That is the BLE_GATTS_EVT_HVN_TX_COMPLETE&amp;nbsp; event fires every 25msec. So the question is how can I make the transfer faster&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>