<?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 check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9676/how-to-check-when-the-stack-is-ready-to-send-notification</link><description>Hi all, 
 I&amp;#39;m using two nRF51 DK to measure ADC input on peripheral side and translate it to central, based on Multilink example.
One software timer is used to perform one ADC conversion every 1 sec, and send a notification to the central throug sd_ble_gatts_hvx</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Oct 2015 08:07:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9676/how-to-check-when-the-stack-is-ready-to-send-notification" /><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35781?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2015 08:07:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2379c51-dcce-4a55-a1eb-dd4d8233c922</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Anders, I changed the MAX_CONN_INTERVAL to 60 ms, but it doesn&amp;#39;t helps.
Yes, we need slave latency to be able to set different send period and save energy on the peripheral side. For example, period could be set from 100 ms up to 2 sec.
How to use slave latency setting?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35780?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2015 07:41:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fcb070c-5eca-4335-bfb0-322a30818a30</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Can you set MAX_CONN_INTERVAL to 60 for the peripheral as well? Slave latency is used for saving power (you sleep through x connection events), do not use this if you need throughput.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35779?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2015 09:59:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ead82980-5fd3-44c9-905c-d39ec69b2fae</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Hi, Andre.
Currently slave settings is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define MIN_CONN_INTERVAL                   MSEC_TO_UNITS(30, UNIT_1_25_MS)           /**&amp;lt; Minimum acceptable connection interval . */
#define MAX_CONN_INTERVAL                   MSEC_TO_UNITS(1000, UNIT_1_25_MS)          /**&amp;lt; Maximum acceptable connection interval (1 second). */
#define SLAVE_LATENCY                       0                                          /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT                    MSEC_TO_UNITS(4000, UNIT_10_MS)            /**&amp;lt; Connection supervisory timeout (4 seconds). */
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;BTW, when I tried to change SLAVE LATENCY, I got the error on sd_ble_gap_ppcp_set() for peripheral and on sd_ble_gap_connect() for central. If it is needed to set connection interval to 30 ms and latency to 33 (at total 1 sec period with 30 ms interval), how it can be made?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35778?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2015 07:22:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46b30622-bda0-47e2-8786-bd71e889219b</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;If you put more packets into the TX_buffer than you send out, it fill naturally fill up. The peripheral is able to send a certain amount of packets each connection interval (6 for S110). With a connection interval of 60ms, it can send (6 * (1/0.060) = 100) packets each second. Even though this is a theoretical maximum, it should be more than enough to send every 100 ms. (See &lt;a href="https://devzone.nordicsemi.com/question/3440/how-do-i-calculate-throughput-for-a-ble-link/"&gt;this&lt;/a&gt; post for more info on BLE throughput). What is the connection intervals on your peripheral application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35777?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 14:24:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b7ffddf-72d3-41ad-803e-3edd171853cd</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Andre, thanks a lot.
Also, I receive the same error when trying to set faster send period. If I try to send packets frequenly than 100 ms, the same error received.
Why this happens if central settings is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MIN_CONNECTION_INTERVAL          MSEC_TO_UNITS(30, UNIT_1_25_MS)                
MAX_CONNECTION_INTERVAL          MSEC_TO_UNITS(60, UNIT_1_25_MS)                
SLAVE_LATENCY                    0                                              
SUPERVISION_TIMEOUT              MSEC_TO_UNITS(4000, UNIT_10_MS)
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35776?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2015 09:38:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4212d16-f00a-4a43-9c10-99c7467e7dd0</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Since the central is off, the packets are not leaving the TX buffer. Adding more buffers will not help you. In your case, this error can be viewed as a symptom of a disconnect. The disconnect event will not happen before a certain amount of connection intervals have passed (this time is often defined as &lt;code&gt;CONN_SUP_TIMEOUT&lt;/code&gt; in our SDK). You can ignore the error if you want, or you can pause the sending of packets until you receive a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s110.api.v8.0.0/group___b_l_e___c_o_m_m_o_n___e_n_u_m_e_r_a_t_i_o_n_s.html#ggaa55e423bfea45f03764a636f2cec7a8ba408a77f131a2d314fbf477cdb2d1e0f6"&gt;BLE_EVT_TX_COMPLETE&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35775?ContentTypeID=1</link><pubDate>Sat, 17 Oct 2015 18:46:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9397072d-0019-406a-9e0e-ea51d1cf9a23</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Would we made the TX buffer like one in HRS_C example, with re-sending packets got this error?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35774?ContentTypeID=1</link><pubDate>Sat, 17 Oct 2015 18:44:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ba890bb-7d28-4492-8bff-023020de56fb</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Dear Anders, you totally right!
Ok, the question is recommendation for program behavior getting this error. Curretnly APP_ERROR_CHECK stops the program or resets CPU depending on debug macro setting. What we should do getting this error code? Could we ignore it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35773?ContentTypeID=1</link><pubDate>Fri, 16 Oct 2015 09:55:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:571b5d39-6d91-47e8-9cae-38b895d66211</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;The 0x3004 error is &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s110.api.v8.0.0/group__ble__err.html#ga901e1bc3ccae29eff9fb31cabdbb5e02"&gt;BLE_ERROR_NO_TX_BUFFERS&lt;/a&gt;.
It is returned when you have no free output buffers to put a packet in. I makes sense that you get this error if you keep trying to send notifications, but the central is off. The packets you put in the buffer after the central is turned off will be stuck there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35772?ContentTypeID=1</link><pubDate>Wed, 14 Oct 2015 15:17:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6f7db81-6fab-4aed-84bd-6fe2701948c6</guid><dc:creator>Dmitry Kr</dc:creator><description>&lt;p&gt;Hi, Anders!&lt;/p&gt;
&lt;p&gt;Thank you, it works fine for cccd writes, but there is an error produced on the disconnection, althought BLE_GAP_EVT_DISCONNECTED is monitored.
I get the 0x3004 error on the code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = sd_ble_gatts_hvx(m_conn_handle, &amp;amp;hvx_params);
if (err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp; err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING) {
APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem typically appears on small timer period (I tested for 100 ms), when I reset central app.
What is wrong here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check when the stack is ready to send notification?</title><link>https://devzone.nordicsemi.com/thread/35771?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2015 13:45:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e777a348-ec3d-4049-ab32-7844a713b3da</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hey.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Starting timer:
You can check the &lt;code&gt;BLE_GATTS_EVT_WRITE&lt;/code&gt; event to see when the cccd is written to 1 (Notifications enabled). Check the &lt;code&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.handle&lt;/code&gt; value. If this is the cccd handle of your characteristic, this means notifications are enabled.
This is a good trigger to start sending data, because it means that the central is ready to receive notifications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stopping timer:
You can check cccd writes here as well, to see if notifications are disabled. You should also stop on the event: &lt;code&gt;BLE_GAP_EVT_DISCONNECTED&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>