<?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 transfer using NUS service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26479/nrf52840-ble-transfer-using-nus-service</link><description>I am writing an application for sending data received over SPI from a non-nordic chip to nrf52840 to nrf uart app using NUS service.
I am using 20 bytes of a packet size the max in NUS. The SPI sampling happens at 4 MHZ.
I am receiving a very low throughput</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 04 Nov 2017 08:10:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26479/nrf52840-ble-transfer-using-nus-service" /><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104203?ContentTypeID=1</link><pubDate>Sat, 04 Nov 2017 08:10:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38a218d3-4c65-4262-b1ce-afafb0ae758f</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;The idea is that all SDK modules and libraries should work as they are an in case they handle some events you should call their handler from you main. All the rest which you do as part of your application logic should live in your main file (or other if you build your modules).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104200?ContentTypeID=1</link><pubDate>Fri, 03 Nov 2017 16:53:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb9e4f01-95fd-4f21-a5a6-e6668d8577c9</guid><dc:creator>pranavsk1994</dc:creator><description>&lt;p&gt;Thanks for the help. Just one more question there are two event handlers one in main file and one in ble_nus services. Where should I check for event
BLE_GATTS_EVT_HVN_TX_COMPLETE?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104204?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 22:00:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:230e4f22-b768-4a0a-a110-3f83b641ba9d</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Well as you see in the code snippet from NUS in SDK &lt;code&gt;ble_nus_send_string&lt;/code&gt; calls in the end &lt;code&gt;sd_ble_gatts_hvx&lt;/code&gt; and you just get the status code as return value from &lt;code&gt;ble_nus_send_string&lt;/code&gt;. So you should examine this code and once it&amp;#39;s &lt;code&gt;NRF_ERROR_RESOURCES&lt;/code&gt; you should store the state variables where in your global transfer you are (before this last &lt;code&gt;ble_nus_send_string&lt;/code&gt; call!) and restart sending process (state machine) once you get any &lt;code&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&lt;/code&gt; event. And repeat until all data are sent out, simple as that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104202?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 19:51:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de6eb2d7-a71c-4484-8ea2-c20b43cea3b8</guid><dc:creator>pranavsk1994</dc:creator><description>&lt;p&gt;Hi, I still have very basic doubts. I have added a snippet of ble_nus code in main question. So basically you are suggesting  to use sd_ble_gatts_hvx() command and pass parameters to it that are set in ble_nus_send_string(), and wait for NRF_ERROR_RESOURCES.&lt;/p&gt;
&lt;p&gt;Then I do ble_nus_send_string() to send data over ble link, and every time transfer is completed I get BLE_GATTS_EVT_HVN_TX_COMPLETE event in&lt;/p&gt;
&lt;p&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)&lt;/p&gt;
&lt;p&gt;after which I again start queing?
But if I queue using sd_ble_gatts_hvx(), and then call ble_nus_send_string, won&amp;#39;t it again queue same data, as the above function is already being called in ble_nus_send_string?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104199?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 12:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46206b92-c2f0-4374-bceb-7efd14236f89</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Pranav,&lt;/p&gt;
&lt;p&gt;You need to queue as much as possible using the sd_ble_gatts_hvx() command (what inside ble_nus_string_send) until you receive NRF_ERROR_RESOURCES meaning all the buffer is queued. And then after that you wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE event telling that there are some packets sent, and the buffer is free, then you can queue again using hvx command.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104207?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 22:31:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cb9320e-861a-445d-9cf5-a29da401e268</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Sure, simply call the function until it will return different error code then OK. Then wait for TX_COMPLETE event and repeat the procedure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104206?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 18:55:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7efc1f1-0aef-46c9-8f5d-63b0326a7f95</guid><dc:creator>pranavsk1994</dc:creator><description>&lt;p&gt;Hi i using this function from NUS service to send data over ble (20 bytes in one packet)&lt;/p&gt;
&lt;p&gt;ble_nus_string_send(&amp;amp;m_nus,buf,20);&lt;/p&gt;
&lt;p&gt;I am collecting data over SPI and in buffer of 20 bytes and then sending it over ble.
You mentioned something of sending at least 3 such packets in one connection interval.
Can you give some insight as in how can I use this to my advantage?
for example , can I write&lt;/p&gt;
&lt;p&gt;ble_nus_string_send(&amp;amp;m_nus,buf,60);&lt;/p&gt;
&lt;p&gt;or I use three different buffers of 20 bytes each and call ble_nus_send_string three times&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104201?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 18:49:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f88909de-64a6-4888-baae-727bfb012294</guid><dc:creator>pranavsk1994</dc:creator><description>&lt;p&gt;Hi I followed the above thread. From which I got to know that throughput depends on connection interval and number of packets that I can send in one interval.
My connection interval  is as follows:
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS)
which turns around to be 16 ms of minimum connection interval.
The function I am using to push data over ble is written below
ble_nus_string_send(&amp;amp;m_nus,buf,20);
from what I have read NUS can transfer 20 bytes of data in packet.
Can you give me some insight how can I use it to transfer multiple such packets in one connection time interval?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104198?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2017 14:11:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e85e2c3-4bdc-44c4-b7a0-fd7bd37ff2e8</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Pranav,&lt;/p&gt;
&lt;p&gt;Maybe you should have a look here: &lt;a href="https://devzone.nordicsemi.com/question/17926/how-should-i-increase-the-throughput-of-my-ble-application/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s pretty old and there are new features in Bluetooth 4.2 and 5.0 that help improve throughput (&lt;a href="https://devzone.nordicsemi.com/blogs/1106/bluetooth-5-2mbps-demo-with-nrf52-series-and-samsu/"&gt;upto 1.3Mbps&lt;/a&gt; )&lt;/p&gt;
&lt;p&gt;But you should follow the above thread first.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 BLE transfer using NUS service</title><link>https://devzone.nordicsemi.com/thread/104205?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2017 19:49:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb3b6b92-6a3f-44f4-a2eb-c3b895ec9352</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;The question is what are both ends of your BLE link, who is Master (GAP Central), what Connection Interval is used and whether you are able to change this. Normally NUS on any nRF5x chip should be able transport at least 3 packets at 7.5ms interval which (being 20B each) gives you at least 8kBps (64kbps). But indeed if one side of the link is some Android phone with 48.75ms interval and single packet per interval then indeed maximum throughput will be around 3.2kbps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>