<?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>sd_ble_gatts_hvx struct is passed as const, yet ble_gatts_hvx_params_t::p_len is modified</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40379/sd_ble_gatts_hvx-struct-is-passed-as-const-yet-ble_gatts_hvx_params_t-p_len-is-modified</link><description>It appears to be an error in the function signature `sd_ble_gatts_hvx()`. 
 Since the call is made via software interrupt, the const qualifier is cast away regardless. 
 So, most likely this is just a form of documentation error? 
 Please confirm, thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Nov 2018 15:26:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40379/sd_ble_gatts_hvx-struct-is-passed-as-const-yet-ble_gatts_hvx_params_t-p_len-is-modified" /><item><title>RE: sd_ble_gatts_hvx struct is passed as const, yet ble_gatts_hvx_params_t::p_len is modified</title><link>https://devzone.nordicsemi.com/thread/156943?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 15:26:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d4f8c38-9768-433a-bfee-363eb149ce98</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;*p_len value can be&amp;nbsp;altered by the softdevice, as per the API documentation:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; @param[in,out] p_hvx_params Pointer to an HVx parameters structure. If @ref ble_gatts_hvx_params_t::p_data
 *                             contains a non-NULL pointer the attribute value will be updated with the contents
 *                             pointed by it before sending the notification or indication. If the attribute value
 *                             is updated, @ref ble_gatts_hvx_params_t::p_len is updated by the SoftDevice to
 *                             contain the number of actual bytes written, else it will be set to 0.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can therefore set the value by de-referencing &amp;quot;*p_hvx_params-&amp;gt;p_len=1234;&amp;quot;, but not change the actual RAM location it points to.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gatts_hvx struct is passed as const, yet ble_gatts_hvx_params_t::p_len is modified</title><link>https://devzone.nordicsemi.com/thread/156903?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 14:00:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:997cac7f-6afc-4424-aae9-87e2c7593ce1</guid><dc:creator>natersoz</dc:creator><description>&lt;p&gt;For example (code snippet):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint16_t const length = 4u;
hvx_params.p_len = &amp;amp;length;
uint32_t error_code = sd_ble_gatts_hvx(&amp;amp;hvx_params);

*hvx_params.p_len = ??
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The comments say that p_len&amp;#39;s pointed to value may by changed by the call (perhaps the buffer did not allow for enough space?) . But p_len is a const pointer.&lt;/p&gt;
&lt;p&gt;Looking for clarification here: Will the returned value of p_len be different than the value passed in? Ever?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gatts_hvx struct is passed as const, yet ble_gatts_hvx_params_t::p_len is modified</title><link>https://devzone.nordicsemi.com/thread/156888?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 13:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ff7716a-9c2c-496c-a758-83238f4a3215</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Interesting topic.&lt;/p&gt;
&lt;p&gt;Provided that the object pointed to does not change memory location, the compiler will accept this. Although, still a bit confusing with the const qualifier for struct pointers in C.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;OK: *p_hvx_params-&amp;gt;p_len = 0;&lt;br /&gt;Not OK: p_hvx_params-&amp;gt;p_len = 0;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>