<?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 long does notification data need to be valid?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31142/how-long-does-notification-data-need-to-be-valid</link><description>Hello, 
 I&amp;#39;m wondering how long do I need to keep the data I want to send alive. 
 Here&amp;#39;s the use case: 
 My data changed so I need to notify the central. Since the data changed, the current attribute value is invalid and needs to be updated. I build</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 08 Mar 2018 20:26:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31142/how-long-does-notification-data-need-to-be-valid" /><item><title>RE: How long does notification data need to be valid?</title><link>https://devzone.nordicsemi.com/thread/123509?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 20:26:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e1cd7cc-23ae-4103-bf23-036b3430edac</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Thanks for your help Edvin! :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How long does notification data need to be valid?</title><link>https://devzone.nordicsemi.com/thread/123220?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2018 11:41:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0946397d-1950-4581-8f6d-e6ff67996ade</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I checked with the SoftDevice team, and they confirmed that the data is stored in a buffer in the SoftDevice. This means that once the sd_ble_gatts_hvx() call returns NRF SUCCESS you can do whatever you want with the data in the hvx_params variable/pointer. It is the data that is stored in the SoftDevice, not the pointer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How long does notification data need to be valid?</title><link>https://devzone.nordicsemi.com/thread/123121?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 15:58:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72477745-2744-4e80-9d67-4cecacab8533</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Hi Edvin, thanks for your answer! Good to know that the hvx_params struct gets buffered. I actually just realized that I asked the wrong question: I really didn&amp;#39;t mean to ask about the hvx_params struct itself, but rather the data pointed by it. How long do I need to keep it alive?&lt;/p&gt;
&lt;p&gt;If the softdevice only stores the pointer, then ok, I can let the hvx_params struct get out of scope. I want to know how long do I need the data pointed by hvx_params.p_data to be kept alive.&lt;/p&gt;
&lt;p&gt;I see in the example you mentioned that the data buffer is declared static in the UART event handler, and gets overwritten every time you get new data. I&amp;#39;m wondering whether the data itself (the one in the UART event handler data buffer) gets buffered by the SoftDevice, or just the pointer to it. Right now I don&amp;#39;t know whether my code works because the SoftDevice buffers the data, or because the data gets transmitted over BLE faster than I can currently overwrite the data in that buffer.&lt;/p&gt;
&lt;p&gt;I hope I made myself a bit clearer now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How long does notification data need to be valid?</title><link>https://devzone.nordicsemi.com/thread/123113?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 15:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9ddb674-4b43-4644-8836-4e0071859f6f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have not seen the source code for this part of the softdevice, but as you can see in e.g. the ble_app_uart example, which uses the ble_nus_string_send() function to send text strings, the ble_gatts_hvx_params_t hvx_params is created within this function, and will &lt;strong&gt;not&lt;/strong&gt; be kept once the ble_nus_string_send() function returns. You will notice that if you try to send several times, it can store up several messages in the sending buffer, but it will eventually return&amp;nbsp;NRF_ERROR_RESOURCES, which indicates that the buffer is full. Then you will have to wait for the BLE_GATTS_EVT_HVN_TX_COMPLETE to be able to queue up more strings in the sending buffer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So to answer your question, yes, the softdevice copies the data from the hvx_params, so you do not have to keep the data after sd_ble_gatts_hvx has returned NRF_SUCCESS. If it returns NRF_ERROR_RESOURCES, you would want to keep the data for the next&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE event, so that you can queue it up in the softdevice again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Even if the packet is lost over the air, the softdevice will retransmit it, and does not need the data from the application to do that.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>