<?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>Send packet continuously over nus</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21878/send-packet-continuously-over-nus</link><description>Is it OK to send multiple packet continuously over nus at below way without waiting for packet transmit complete?

 i=UserUart.RxBuf[1]+2;
 index = 0;
 while(i&amp;gt;0)
 {
 if(i&amp;gt;20)
 {
 err_code = ble_nus_string_send(&amp;amp;m_nus, UserUart.RxBuf+index, 20</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 May 2017 00:55:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21878/send-packet-continuously-over-nus" /><item><title>RE: Send packet continuously over nus</title><link>https://devzone.nordicsemi.com/thread/85895?ContentTypeID=1</link><pubDate>Tue, 09 May 2017 00:55:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c595d3b0-0c70-4255-ac7e-eeae5df727f7</guid><dc:creator>Fiske</dc:creator><description>&lt;p&gt;Can I modify the code to below? Can below code make sure that all packet are deliveried&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  i=UserUart.RxBuf[1]+2;
       index = 0;
       while(i&amp;gt;0)
       {
         if(i&amp;gt;20)
         {
           while((err_code = ble_nus_string_send(&amp;amp;m_nus, UserUart.RxBuf+index, 20)) ==BLE_ERROR_NO_TX_PACKETS)
           {           
                      ;
           }
           if (err_code != NRF_ERROR_INVALID_STATE)
           {
               APP_ERROR_CHECK(err_code);
           }
           i -= 20;
           index += 20;
         }
         else 
         {
           while((err_code = ble_nus_string_send(&amp;amp;m_nus, UserUart.RxBuf+index, i))====BLE_ERROR_NO_TX_PACKETS) 
            {

                         ;
            }
           if (err_code != NRF_ERROR_INVALID_STATE)
           {
               APP_ERROR_CHECK(err_code);
           }
           i = 0;

         }

       }
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send packet continuously over nus</title><link>https://devzone.nordicsemi.com/thread/85894?ContentTypeID=1</link><pubDate>Mon, 08 May 2017 13:52:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95e5544d-04ac-430d-b24e-ad3ebb2ced4f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You are correct, Turbo.  I mentioned about the return code TX buffer full that he need to handle. It&amp;#39;s called now BLE_ERROR_NO_TX_PACKETS, was BLE_ERROR_NO_TX_BUFFERS before. And yes, he need to handle that return code and not send it to APP_ERROR_CHECK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send packet continuously over nus</title><link>https://devzone.nordicsemi.com/thread/85893?ContentTypeID=1</link><pubDate>Mon, 08 May 2017 11:48:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e8990ed-6560-431a-b120-e016227019d0</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Contrary to Hung Bui&amp;#39;s answer, your code will &lt;strong&gt;not&lt;/strong&gt; work in case you go over 6 or 7 times 20 bytes.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;ble_nus_string_send()&lt;/code&gt; function will return an error code (&lt;code&gt;BLE_ERROR_NO_TX_PACKETS&lt;/code&gt;), and your app goes to whatever &lt;code&gt;app_error_handler()&lt;/code&gt; you have set up.&lt;/p&gt;
&lt;p&gt;You need to handle at least this error indicating that the SD has no more TX buffers left.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Send packet continuously over nus</title><link>https://devzone.nordicsemi.com/thread/85896?ContentTypeID=1</link><pubDate>Mon, 08 May 2017 08:00:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f307391-317d-4c5b-a8ba-4faa91b9b802</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Fiske,&lt;/p&gt;
&lt;p&gt;Yes you can. You will receive TX buffer full return code when the buffer is full (7 packets with high bw) and this way keeps the CPU running all the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>