<?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>Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70092/maximum-number-of-bytes-transmitted-from-own-service-and-characteristic</link><description>Hi, 
 I am currently working with the nrf52840, ble_app_uart example under the ble_peripheral folder. Using the tutorial below: 
 https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Apr 2021 09:40:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70092/maximum-number-of-bytes-transmitted-from-own-service-and-characteristic" /><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/303063?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 09:40:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86e86c9a-c814-4d9b-8cdc-48387e8d4ab8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What you are seeing is expected, then. You should only print the actual length of the data. Anything after that would be whatever happens to be in that memory from before.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/302314?ContentTypeID=1</link><pubDate>Mon, 29 Mar 2021 08:31:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fae6d359-bf61-4655-99f7-b2c9ee493b70</guid><dc:creator>Ananye</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Sorry for my late reply. I have been testing this feature again recently. I am actually showing the data in the nRF connect app. In the app, when I monitor the characteristic value, I see that it prints upto the maximum length instead of the length value in the update_characteristic function.&lt;/p&gt;
&lt;p&gt;The remaining left bytes are just shown up as random bytes.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Ananye&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287759?ContentTypeID=1</link><pubDate>Wed, 06 Jan 2021 14:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bdae646-b965-47c8-a9a9-aa4132e38469</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
[quote user="Ananye"]As you can see, the function gets the parameter &amp;#39;length&amp;#39; which is then assigned to hvx_params.p_len. According to the nordic tutorial, this number specifies how many bytes should be displayed.[/quote]
&lt;p&gt;this looks good so far. To me this seems like just an issue with printing the data. How do you display this on the peer device? If it is a nRF, can you share the code that prints it? If it is some other tool, are you sure that tool correctly uses that value and not the maximum value?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287575?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 19:27:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:395f5fdb-481f-4113-99fb-a3dcb001568d</guid><dc:creator>Ananye</dc:creator><description>&lt;p&gt;Hi, below is snippets of my code.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;//This is found in the function our_char_add() - based on the tutorial attached above.
//In this case my max_len is set to 42. 
//This code is called only ONCE, when we initialize our service.
    
    
    // OUR_JOB: Step 2.H, Set characteristic length in number of bytes
    attr_char_value.max_len     = 42;                                       
    attr_char_value.init_len    = 4;
    uint8_t value[4]            = {0x12,0x34,0x56,0x78};
    attr_char_value.p_value     = value;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then, when I am updating the characteristic this is the function I call. Here, I am passing in the actual length of my data, which I have calculated using pointers. That length is then set to the parameter &amp;#39;len&amp;#39;. Generally this value comes to around 35. &lt;pre class="ui-code" data-mode="c_cpp"&gt;void our_temperature_characteristic_update(ble_os_t *p_our_service, char* temperature_value, int length)
{
    // OUR_JOB: Step 3.E, Update characteristic value
    if (p_our_service-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID){//if the connection is valid. Earlier: p_our_service-&amp;gt;conn_handle

        uint16_t               len = (uint16_t)length;
        ble_gatts_hvx_params_t hvx_params;
        memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = p_our_service-&amp;gt;char_handles.value_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = 0;
        hvx_params.p_len  = &amp;amp;len;
        hvx_params.p_data = (uint8_t*)temperature_value;  

        sd_ble_gatts_hvx(p_our_service-&amp;gt;conn_handle, &amp;amp;hvx_params);



    }
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the function gets the parameter &amp;#39;length&amp;#39; which is then assigned to hvx_params.p_len. According to the nordic tutorial, this number specifies how many bytes should be displayed.&lt;/p&gt;
&lt;p&gt;Please let me know if further clarification is needed.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287405?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 07:41:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:971c3a47-cda6-4d9b-9968-12d05a4456ba</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;p&gt;Then, under step 3E I call, our_temperature_characteristic_update() and pass in the desired length of my actual data. I set that value to p_len. In my case, this value is set to 35.&lt;/p&gt;
&lt;p&gt;So, ideally I should be observing only 35 bytes displayed but I see extra data displayed which I don&amp;#39;t want.&lt;/p&gt;[/quote]
&lt;p&gt;I think we need to see some code in order to understand the issue. Do you take into account the received data length when you print the data buffer, or do you always print the maximum length?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287385?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 05:42:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4a23285-e533-45c8-97fd-f42b97a965eb</guid><dc:creator>Henry_Chou</dc:creator><description>&lt;p&gt;It&amp;#39;s a usual technique for some case in char. format..&lt;/p&gt;
&lt;p&gt;Your case :&lt;/p&gt;
&lt;p&gt;&amp;nbsp;end words method ( as \r\n 0x0d 0x0a) :&lt;/p&gt;
&lt;p&gt;00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f&lt;/p&gt;
&lt;p&gt;10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f&lt;/p&gt;
&lt;p&gt;20 21 22 0d 0a ff&amp;nbsp; ff ff ff ff&lt;/p&gt;
&lt;p&gt;First byte for length&lt;/p&gt;
&lt;p&gt;&amp;nbsp;23&amp;nbsp;&amp;nbsp;&lt;span&gt;00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e&lt;/p&gt;
&lt;p&gt;1f 20 21 22 ff ff ff ff ff ff&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287377?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 04:19:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2400680b-fca9-4652-a7e8-87a7f3bccca1</guid><dc:creator>Ananye</dc:creator><description>&lt;p&gt;Hi, sorry I didn&amp;#39;t quite understand. What are &amp;#39;end words&amp;#39; and first byte format?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximum number of bytes transmitted from own service and characteristic</title><link>https://devzone.nordicsemi.com/thread/287371?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 02:48:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d2c8d53-22a6-4928-8c22-a39796c61d98</guid><dc:creator>Henry_Chou</dc:creator><description>&lt;p&gt;You may add on the end words to make sure your data length or define your data length in your first byte format.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>