<?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>UART example data packet size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94458/uart-example-data-packet-size</link><description>Hallo, 
 currently I want to test a connection between an nRF52840-DK and a Smartphone. For that, I used the Nordic UART Bridge Service (NUS) sample to start with. 
 When testing the data packet size, I found that I can transmit only 20 Bytes without</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Dec 2022 12:29:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94458/uart-example-data-packet-size" /><item><title>RE: UART example data packet size</title><link>https://devzone.nordicsemi.com/thread/402268?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2022 12:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:317a6cf0-1529-46d7-a6ec-46655910977e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Axel&lt;/p&gt;
&lt;p&gt;Karl is currently out of office and I will handle your case in the mean time.&amp;nbsp;&lt;/p&gt;
[quote user="axel_s"]we managed to have 505 bytes transferred by means of a single call of bt_nus_send(..). The maximum might be a few bytes higher, but 510 didn&amp;#39;t work. [/quote]
&lt;p&gt;What about 509 bytes?&lt;/p&gt;
&lt;p&gt;The ATT protocol adds a 3 byte header to most packets (one byte for the ATT opcode and 2 bytes for the ATT handle), but to be honest I always assumed that the header would come on top of the 512 byte packet, and not be counted as a part of it. This could be an implementation issue though.&amp;nbsp;&lt;/p&gt;
[quote user="axel_s"]In the core specification v5.2, there is a statement in Vol.3, Part F, 3.2.9: &amp;quot;The maximum length of an attribute value shall be 512 octets.&amp;quot; which seems to fit to our findings (a few bytes might be used e.g. for some control information).[/quote]
&lt;p&gt;Correct. This is a spec limitation. The only way to have longer packets be automatically de-assembled and assembled would be to forego the ATT layer altogether, and use L2CAP connection oriented channels.&amp;nbsp;&lt;/p&gt;
[quote user="axel_s"]I know that the standard writers usually don&amp;#39;t care about implementation, but isn&amp;#39;t there any feedback regarding those points, which obviously don&amp;#39;t fit to &amp;quot;low energy&amp;quot;?[/quote]
&lt;p&gt;I can only speculate what the spec designers where thinking when making these decisions, but when the LE mode was added the primary uses cases where on sensor or peripheral type applications where you didn&amp;#39;t have to send large amounts of data very often. Keep in mind that in the Bluetooth 4.0 specification the maximum amount of data you could send in one packet was only 20 bytes, and overall throughput was typically limited to no more than 100kbps or less.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then this was improved with the ability to send up to 244 bytes of user data in BT 4.2, and the inclusion of the high speed 2M mode in BT 5, to take the total throughput up to around 1.3Mbps in cases where both the central and peripheral supports these features.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is a fact though that if you want to achieve the optimal throughput and power efficiency when streaming lots of&amp;nbsp;data over GATT you should handle the de-assembly and assembly manually in the application, and scale the notifications after your data length to ensure that you don&amp;#39;t get into these kind of unevenly sized on air packet situations.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART example data packet size</title><link>https://devzone.nordicsemi.com/thread/401665?ContentTypeID=1</link><pubDate>Wed, 21 Dec 2022 09:12:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a487cd0-29b0-49fd-82ac-654ab006a79f</guid><dc:creator>axel_s</dc:creator><description>&lt;p&gt;Hallo Karl,&lt;/p&gt;
&lt;p&gt;at first, meanwhile I updated to ncs 2.2 and Zephyr 3.2.&lt;/p&gt;
&lt;p&gt;We did a few more tests, using extended versions of the UART example. We want to connect an nRF52840-DK and a smartphone with our own app.&lt;/p&gt;
&lt;p&gt;By setting in the config file:&lt;/p&gt;
&lt;p&gt;CONFIG_BT_BUF_ACL_RX_SIZE=2048&lt;br /&gt;CONFIG_BT_BUF_ACL_TX_SIZE=2048&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (max. for both sizes is 65535)&lt;br /&gt;CONFIG_BT_L2CAP_TX_MTU=2000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (max. is 2000)&lt;br /&gt;CONFIG_BT_CTLR_DATA_LENGTH_MAX=251&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ( max. is 251)&lt;/p&gt;
&lt;p&gt;we managed to have 505 bytes transferred by means of a single call of bt_nus_send(..). The maximum might be a few bytes higher, but 510 didn&amp;#39;t work. Within an automatically generated autoconf.h (including our settings unchanged) I couldn&amp;#39;t find any other number corresponding to the 505..510 bytes. Also on smartphone side there is no number explaining that maximum size.&lt;/p&gt;
&lt;p&gt;In the air, there is a split into three frames with PDU lengths 253/253/13 (verified by our sniffer). Obviously, the stack manages the split and the re-assembly on reception side.&lt;/p&gt;
&lt;p&gt;In the core specification v5.2, there is a statement in Vol.3, Part F, 3.2.9: &amp;quot;The maximum length of an attribute value shall be 512 octets.&amp;quot; which seems to fit to our findings (a few bytes might be used e.g. for some control information).&lt;/p&gt;
&lt;p&gt;But anyway, I wonder about these results. When it is necessary to use three frames on air because of the max. length of a single frame, why limit the overall length in this way to 512 bytes? Especially from the energetic point of view (BT LOW ENERGY), it is a waste of resources to have the third frame of 13 bytes PDU only. In my mind, limiting to about 500 bytes would be ok to have two frames on air, or extending the limit to about 750 bytes to fill up the third frame too. And one could ask why it isn&amp;#39;t possible to use four/five/... frames on air to have larger maximum packets transferred. Such a wish doesn&amp;#39;t contrast to &amp;quot;low energy&amp;quot;: I might use it, but I don&amp;#39;t have to. &lt;/p&gt;
&lt;p&gt;I know that the standard writers usually don&amp;#39;t care about implementation, but isn&amp;#39;t there any feedback regarding those points, which obviously don&amp;#39;t fit to &amp;quot;low energy&amp;quot;?&lt;/p&gt;
&lt;p&gt;Merry Xmas&lt;/p&gt;
&lt;p&gt;Axel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART example data packet size</title><link>https://devzone.nordicsemi.com/thread/399440?ContentTypeID=1</link><pubDate>Wed, 07 Dec 2022 13:41:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f7a7ae5-3ab9-4939-a47a-e793a196aa1b</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Axel&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="axel_s"] currently use Zephyr 2.7.99 and ncs 1.9.1.[/quote]
&lt;p&gt;Thank you for your patience with this, and thank for you clarifying.&lt;/p&gt;
[quote user="axel_s"]That&amp;#39;s true for single packets. But in case of a service I want to hand over a larger packet to the service, expecting that larger packet delivered automatically to the receiver, which should hand it back also as one large packet. As I wrote, the bt_nus_send(..) contains a uint16_t length parameter, indicating that my intention is possible.[/quote]
&lt;p&gt;Yes, you can indeed queue more than the packet limit for sending, in which case the SoftDevice Controller will divide the data into packets that conform to the limit before sending. How much data you can allocate at any one time depends on your configuration of the buffer that the service is using.&lt;/p&gt;
[quote user="axel_s"]And in general I won&amp;#39;t modify any service nor create a new one. I simply want to transfer a number of bytes from A to B or vice versa. I can&amp;#39;t understand why this most primitive issue isn&amp;#39;t existing as a kind of basic service as well as in a basic example (Yes, there is no maximum for &amp;quot;larger packets&amp;quot;. But an example for e.g. 1000 Byte combined with the statement &amp;quot;length limit according to available memory&amp;quot; would be nice.). Everything else is more specialised. But in the end, only a simple solution is a good one.[/quote]
&lt;p&gt;It is hard to make a simple example that works ideally for every use-case, without having to make any modifications or change any configurations.&lt;br /&gt;Please see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/84226/increasing-ble-mtu-data-length-for-notifications-on-ncs-v1-8"&gt;this answer by my colleague Amanda regarding how you could increase the MTU size to the maximum allowable size&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Are you encountering any specific issues when you are making these modifications?&lt;br /&gt;If so, please elaborate, so that we may help you resolve them.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART example data packet size</title><link>https://devzone.nordicsemi.com/thread/398706?ContentTypeID=1</link><pubDate>Fri, 02 Dec 2022 09:09:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93b07778-634d-49e7-86c2-8f8557843169</guid><dc:creator>axel_s</dc:creator><description>&lt;p&gt;Hallo Karl,&lt;/p&gt;
&lt;p&gt;thanks for the info, I&amp;#39;ll do some more tests. I currently use Zephyr 2.7.99 and ncs 1.9.1.&lt;/p&gt;
&lt;p&gt;&amp;quot;The maximum total packet length in BLE is 255 bytes, and you also loose a couple of bytes to overhead, and so your max MTU size is 247 bytes.&amp;quot; That&amp;#39;s true for single packets. But in case of a service I want to hand over a larger packet to the service, expecting that larger packet delivered automatically to the receiver, which should hand it back also as one large packet. As I wrote, the bt_nus_send(..) contains a uint16_t length parameter, indicating that my intention is possible.&lt;/p&gt;
&lt;p&gt;And in general I won&amp;#39;t modify any service nor create a new one. I simply want to transfer a number of bytes from A to B or vice versa. I can&amp;#39;t understand why this most primitive issue isn&amp;#39;t existing as a kind of basic service as well as in a basic example (Yes, there is no maximum for &amp;quot;larger packets&amp;quot;. But an example for e.g. 1000 Byte combined with the statement &amp;quot;length limit according to available memory&amp;quot; would be nice.). Everything else is more specialised. But in the end, only a simple solution is a good one.&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Axel&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART example data packet size</title><link>https://devzone.nordicsemi.com/thread/398587?ContentTypeID=1</link><pubDate>Thu, 01 Dec 2022 14:51:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ca842d2-576e-43e5-b9a8-075e76375ffe</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Axel,&lt;br /&gt;&lt;br /&gt;Could you specify which SDK you are working with - nRF5 SDK or nRF Connect SDK?&lt;br /&gt;&lt;br /&gt;In general it is the Central device (phone, in this case) that determines the connection parameters that will be used for the connection.&lt;br /&gt;A peripheral may only request to have these parameters updates to its preferred values, but the central has the last say and can ultimately just reject these requests.&lt;br /&gt;The peripheral then only have the choice to either accept the parameters that the central is using, or to terminate the connection.&lt;/p&gt;
[quote user=""]&lt;p&gt;When testing the data packet size, I found that I can transmit only 20 Bytes without error. In case of e.g. 21 data bytes, There is an error:&lt;/p&gt;
&lt;p&gt;W: No ATT channel for MTU 24&lt;br /&gt;W: No buffer available to send notification&lt;/p&gt;[/quote]
&lt;p&gt;You could also modify the Nordic UART service to expect larger transfers.&lt;/p&gt;
[quote user=""]This definition alone leads to the assumption that at least more than 255 bytes should be possible. Also the fact that it is a UART example means in my mind that it should be possible to transfer larger data packets.[/quote]
&lt;p&gt;The maximum total packet length in BLE is 255 bytes, and you also loose a couple of bytes to overhead, and so your max MTU size is 247 bytes.&lt;br /&gt;You might also benefit from seeing &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html"&gt;the SoftDevice Throughput documentation for more information about how the chosen parameters affects your throughput&lt;/a&gt;.&lt;br /&gt;If you do queue more than the MTU size for transfer the transfer will be split into multiple packets, and reassembled on the receiving side once the last fragment is received.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>