<?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>How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22945/how-to-send-more-than-8-packets-of-20bytes-to-ble-app-using-notification</link><description>Hello,
I am using sdk12 and uart code. I want to send my sensor data readings to ble app. For that I have modified the ble_app_uart code and I am able to send 8 packets of 20 bytes using ble_nus_string_send function. But my challenge is I am not getting</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Jun 2017 12:42:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22945/how-to-send-more-than-8-packets-of-20bytes-to-ble-app-using-notification" /><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90274?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2017 12:42:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f9c2bee-ebac-4917-b367-3abcbd27df73</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hi,
Thanks for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90273?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2017 12:32:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a3e1aaa-207b-4ed0-a6d6-d35fcc43505b</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;This code will send what you have stored in &lt;code&gt;data&lt;/code&gt; to the &lt;strong&gt;UART&lt;/strong&gt; module, and the data will be printed on the terminal when you get the &lt;code&gt;BLE_GATTS_EVT_WRITE&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90272?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2017 06:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e547caa-50ed-44d7-b0b8-40f2de349a10</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hi Sigurd,
I have found out a problem. My mechanism was such that when I write in characteristic notification is enabled and my function call will send the data via ble. Here is code snippet&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; case BLE_GATTS_EVT_WRITE:
						if(m_nus.is_notification_enabled == true)
						{
					//		err_code = sd_nvic_SetPendingIRQ(DATA_SEND_IRQn);
					//		APP_ERROR_CHECK(err_code);
							nus_data_handler(&amp;amp;m_nus, data, 40);
						}
						           
            break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this stops after sending 8 packets and returns me error as discussed above.&lt;/p&gt;
&lt;p&gt;When I call my function in for loop in main function it sends complete packets without missing any thing. So what could be possible errors while I send when user writes something to write characteristics?
Thanks,
Shailav&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90269?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 13:01:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fbfd48e-f0be-4443-b7d0-30a14c3495e2</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hi ,
I am not able to receive all data from flash. Below is my code snippet. Please suggest me changes.
while(1)
{
for(i=0;i&amp;lt;20;i++)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;		data[i] = data_flash[j]; //data= buffer to send to ble, data_flah=data stored in flash
		NRF_LOG_INFO(&amp;quot;%d %d %d bledata \r\n&amp;quot;,data[i], i, j);
			
			nrf_delay_ms(1000);
			j++;
		}
		

		
    err_code = ble_nus_string_send(&amp;amp;m_nus, data,BLE_NUS_DATA_CHAR_LEN);
		NRF_LOG_INFO(&amp;quot;%d errcode \r\n&amp;quot;,err_code);
    if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
        err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
        err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp;
err_code != (NRF_ERROR_STK_BASE_NUM+NRF_ERROR_NO_MEM)&amp;amp;&amp;amp;
  err_code != (BLE_ERROR_NO_TX_PACKETS)  //added as per your suggestions
			)
    {
        APP_ERROR_CHECK(err_code);
    }

			
			if (i==20)
			{
				for(i=0;i&amp;lt;20;i++)
				 {
						data[i] = 0; //clearing data and breaking into 20 bytes
			   }
				
				 i=0;
				
			}
			
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;BLE EVENTS:&lt;/p&gt;
&lt;p&gt;case BLE_EVT_TX_COMPLETE:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;							  if(!ble_buffer_available) tx_complete = true;
        break;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90271?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 12:02:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47ea7802-c543-4a57-876b-5215247c6e95</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;From the photo you uploaded, you are getting error code value of 12292. If you &lt;a href="http://www.binaryhexconverter.com/decimal-to-hex-converter"&gt;convert this value to hex&lt;/a&gt;, the value becomes 0x3004. And 0x3004 is  &lt;code&gt;BLE_ERROR_NO_TX_PACKETS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This error code is defined in a file called ble_err.h, as&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define BLE_ERROR_NO_TX_PACKETS          (NRF_ERROR_STK_BASE_NUM+0x004) /**&amp;lt; Not enough application packets available on this connection. */
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where &lt;code&gt;NRF_ERROR_STK_BASE_NUM&lt;/code&gt; is defined as (0x3000) in &lt;code&gt;nrf_error.h&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90270?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 11:55:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5766bbf9-6551-4633-9410-4addc0699cbe</guid><dc:creator>Newbie</dc:creator><description>&lt;p&gt;Hi Sigurd,
Where is the macro BLE_ERROR_NO_TX_BUFFERS defined? My code gives me error as undefined variable.
Whats the value of this error code?
I am getting error as attached above.Find the image attached above in question.
Thanks,
Shailav&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to send more than 8 packets of 20bytes to ble app using notification</title><link>https://devzone.nordicsemi.com/thread/90268?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2017 11:28:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5d65c0a-e47a-4221-a723-fe6973b1d263</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;With &lt;strong&gt;S132 v.3.0.0 (SDK12)&lt;/strong&gt; you will get a &lt;code&gt;BLE_ERROR_NO_TX_PACKETS&lt;/code&gt; error code when the buffer is full (7 packets with high BW). You have to wait for any pending packets to be sent and retry later. You can handle this in several ways. If you don’t care about wasting CPU time and current, you can just make some sort of &lt;code&gt;if(returned error == BLE_ERROR_NO_TX_PACKETS)&lt;/code&gt; check, and simply keep trying again until the function return &lt;code&gt;NRF_SUCCESS&lt;/code&gt;. A better approach is to use the &lt;code&gt;BLE_EVT_TX_COMPLETE&lt;/code&gt; event, and keep track of the buffers that you can use.
There are many posts about this on Devzone, here are is a list of some you can check out:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/79118/nrf52-recommended-ways-to-reduce-and-deal-with-3004/?answer=79161#post-id-79161"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/69102/problem-when-i-send-more-than-8-packets/?answer=69108#post-id-69108"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/17211/error-code-0x3004/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/118906/ble_error_no_tx_buffers/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Note that this is changed in &lt;strong&gt;S132 v.4.0.2 (SDK13)&lt;/strong&gt;, here the application packet concept has been replaced with a dedicated transmission queue for Handle Value Notifications. The number of Handle Value Notifications that can be queued is now configured by &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v5.0.0/structble__gatts__conn__cfg__t.html?cp=2_3_1_0_0_2_4_4_0"&gt;ble_gatts_conn_cfg_t::hvn_tx_queue_size&lt;/a&gt; by the &lt;strong&gt;application&lt;/strong&gt;. When the queue is full, the function call will now return &lt;code&gt;NRF_ERROR_RESOURCES&lt;/code&gt;. &lt;code&gt;BLE_ERROR_NO_TX_PACKETS&lt;/code&gt; / &lt;code&gt;BLE_ERROR_NO_TX_BUFFERS&lt;/code&gt; is no longer used. A &lt;code&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&lt;/code&gt; event will be issued as soon as the transmission of the notification is complete.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>