<?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>Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107694/unreliable-ble-connection-for-continuos-high-bandwidth-data-stream</link><description>I want to send a continuos stream of sensor data over BLE, currently using the NUS GATT profile, connecting directly to a third-party device e.g. computer or phone. 
 The bandwidth required is about ~256kbit/s so in theory more than enough bandwidth available</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 31 Jan 2024 07:45:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107694/unreliable-ble-connection-for-continuos-high-bandwidth-data-stream" /><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466873?ContentTypeID=1</link><pubDate>Wed, 31 Jan 2024 07:45:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:880a46fc-b7f0-4a1d-b8a0-8992ff217e52</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Thanks Hugh, looks correct to me at least &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466841?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2024 20:30:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e0f0ff2-8b15-44cb-9117-92e7636ae0c8</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I wrote this to include in the code, as an aide memoire, hopefully it&amp;#39;s about right :-)&lt;pre class="ui-code" data-mode="c_cpp"&gt;// +-----------------------------------------------------------------------------------------------------------------+
// |                                             BLE Data Packet Min/Max                                             |
// +-----------------------------------------------------------------------------------------------------------------+
// |                                             1MHz: 10/265 octets, 2MHz: 11/266 octets                            |
// +----------+--------+--------------------------------------------------------------------------------------+------+
// |          | Access |                                                                                      |      |
// | Preamble | Address|         Protocol Data Unit PDU                                                       | CRCC |
// +----------+--------+--------------------------------------------------------------------------------------+------+
// |   1 (2)  |    4   |                                                   2-257                              |  3   |
// |          |        +-----------+------------------------------------------------------------------+-------+      |
// |          |        | LL Header |  Payload                                                         |  MIC  |      |
// |          |        +-----------+------------------------------------------------------------------+ (opt) |      |
// |          |        |   2       |                                       0-251                      |   4   |      |
// |          |        |           +--------+---------------------------------------------------------+       |      |
// |          |        |           | L2CAP  |                                                         |       |      |
// |          |        |           | Header |  ATT Data                                               |       |      |
// |          |        |           +--------+---------------------------------------------------------+       |      |
// |          |        |           |   4    |                              0-247                      |       |      |
// |          |        |           |        +-----+-------+-------------------------------------------+       |      |
// |          |        |           |        | ATT | ATT   |                                           |       |      |
// |          |        |           |        | Op  | Attrib|  ATT Payload                              |       |      |
// |          |        |           |        +-----+-------+-------------------------------------------+       |      |
// |  1 (2)   |   4    |  2        |   4    |  1  |  2    |                0-244                      |  (4)  |  3   |
// +----------+--------+-----------+--------+-----+-------+-------------------------------------------+-------+------+&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466832?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2024 19:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26211687-08df-4f61-aa45-e6745323fc2b</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;ah I see! Thanks for the clarification&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466796?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2024 15:11:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cceaea9-ff76-41bf-85d0-b08ca3cc5fe7</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a bit of semantics I guess, what you define as the payload or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The total packet length is higher, that is correct. You get either 10 or 14 bytes in addition to the payload I mentioned, depending on whether or not encryption is enabled.&lt;/p&gt;
&lt;p&gt;The total packet looks like this:&lt;/p&gt;
&lt;p&gt;1 byte preamble + 4 byte access address + 2 byte packet header + 0-251 byte data payload + 3 byte CRC (+ 4 byte MIC)&lt;/p&gt;
&lt;p&gt;This totals 265 bytes when using 251 byte payload and encryption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466627?ContentTypeID=1</link><pubDate>Mon, 29 Jan 2024 21:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b2c9254-cbd7-426b-bd29-a2c76e51ecac</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;oh maybe I misunderstood something about the L2CAP layer. I thought the packet length was 265 and with overhead its 251 data bytes&lt;br /&gt;Was going by &lt;a href="https://interrupt.memfault.com/blog/ble-throughput-primer"&gt;interrupt.memfault.com/.../ble-throughput-primer&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466511?ContentTypeID=1</link><pubDate>Mon, 29 Jan 2024 12:46:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25766f72-ff49-44d0-b8f9-5fb4cc222239</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
[quote user="DiodesDelight"]You mean as in setup the data stream so I send 244bytes per transaction/notification?[/quote]
&lt;p&gt;Yes, split your data into 244 byte chunks to avoid link layer segmentation.&amp;nbsp;&lt;/p&gt;
[quote user="DiodesDelight"]but where does the 244 comes from, isn&amp;#39;t the maximum 251bytes of actual data?[/quote]
&lt;p&gt;The on air payload is 251 bytes, correct (or 255 with encryption enabled, since you need 4 bytes for the MIC), but the L2CAP layer reserves 4 of those for the L2CAP header, and the ATT layer reserves 3 for the ATT header, leaving you with 244 bytes for user data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466319?ContentTypeID=1</link><pubDate>Sat, 27 Jan 2024 02:40:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7e393b3-0b58-4a08-b8f1-35d614365c3e</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Could you go into detail what you mean with &amp;quot;scale the notifications after the data length&amp;quot;?&lt;br /&gt;You mean as in setup the data stream so I send 244bytes per transaction/notification? That would make sense to me to make sure to send only one packet per notification and do more frequent notifications but where does the 244 comes from, isn&amp;#39;t the maximum 251bytes of actual data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466158?ContentTypeID=1</link><pubDate>Fri, 26 Jan 2024 08:21:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0cac43c-ef27-43c7-a385-0a4b998c4cb8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Very good to hear that you found the issue &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Another tip to maximize throughput is to scale the notifications after the data length, to avoid packet fragmentation. If you send 244 bytes of data per packet you should get the most efficient transfer when using the maximum data length.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466106?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 18:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a0f60c6-e487-47ad-a2c7-02ccb3050898</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;heh okay I found the issue. There was a &lt;br /&gt;CONFIG_BT_USER_DATA_LEN_UPDATE=y&lt;br /&gt;CONFIG_BT_USER_PHY_UPDATE=y&lt;br /&gt;lurking after my&lt;br /&gt;CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y&lt;br /&gt;&lt;br /&gt;which disabled actually updating the phy and data length as I&amp;#39;m not doing that explicitly in my app as its done in the throughput example. I&amp;#39;m guessing this fragment made it in when copying some connection parameters over from the passthrough example.&lt;br /&gt;I also noticed while both sides advertised 2M PHY initially they never actually switched to it.&lt;br /&gt;Removed those config lines and now its updating everything automatically and runs just fine at full sampling bandwidth :)&lt;br /&gt;Thanks for your pointers &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt; they put me on the right track. I compared captures between throughput sample and my app and saw that that exchange was missing.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706208393558v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466095?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 16:30:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f5f93b2-7d47-4c9e-845b-b8b1aeecd871</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Yea sure, is there a way to privately share it? Would like to avoid sharing MAC addresses of the BLE devices publicly.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s odd, both in Zephyr it confirms the MTU via bt_nus_get_mtu() and also sniffing the traffic it seems to ack the MTU.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706200125118v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/466000?ContentTypeID=1</link><pubDate>Thu, 25 Jan 2024 12:56:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9496d654-bb99-4ec7-9a11-01af9dca6757</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;Looking at the trace excerpt it seems that the data length is not increased, which means all the data needs to be segmented in 27 byte packets (of which only 20 bytes include user data), and this will severely impact the overall throughput.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This could either be caused by a limitation on the Windows side (hopefully not), or a configuration issue after establishing the connection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Would you be able to save the full trace to file and share it in the case?&lt;/p&gt;
&lt;p&gt;Then I can take a look at it and see if I can spot an issue with the data length request procedure.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you can share your project configuration this could also be useful (prj.conf).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/465885?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 23:20:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd907216-9902-455a-830d-21657f7df242</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;I&amp;#39;m mostly testing with my Windows machine as the central. It has a Mediatek chipset for Bluetooth.&lt;br /&gt;I had also tried out the NUS Central sample but similar behaviour occurred though I have not dug deeper there other than upping the UART baud rate.&lt;br /&gt;In the end the application would have to work at least with your average Windows or Mac for now, later on also with phones so it would have to be somewhat reliable enough with third party chipsets too in any case.&lt;br /&gt;For bandwidth testing I stuck to the nRF5340DK instead of the custom hardware.&lt;/p&gt;
&lt;p&gt;Good call with testing dummy data, I don&amp;#39;t think I have done that so far. From the profiling so far it didn&amp;#39;t seem too much of a data handling issue as it was usually hanging at nus_send but good to double check.&lt;br /&gt;Below is a short block of what I captured with a 16hz sampling rate being transmitted.&lt;br /&gt;&lt;br /&gt;Both MTU size and 2M PHY were ack&amp;#39;ed by the central during connection handshake.&lt;br /&gt;But there are multiple L2CAP fragments between each event. I&amp;#39;m not knowledgable enough on the BLE PHY end to know if that is how a transmission works or if that should show up as a single packet equal to MTU size.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1706137589837v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unreliable BLE connection for continuos high bandwidth data stream</title><link>https://devzone.nordicsemi.com/thread/465751?ContentTypeID=1</link><pubDate>Wed, 24 Jan 2024 10:28:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eef28837-67c0-4358-96d7-8ae17d33eb58</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;It is odd that you would get such low rates. Are you running Nordic devices on both sides of the link, or are you communicating with something else, like a smart phone?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you using custom hardware or standard devkits?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you confirm from the sniffer trace that data length and large MTU is probably utilized?&amp;nbsp;&lt;br /&gt;Could you see many packets sent back to back within a connection event, or only a single packet pr connection event?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For testing purposes I would recommend starting with dummy data just to rule out an issue in the handover between the DMIC reading and the Bluetooth transmission.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>