<?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>Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60624/maximizing-uart-over-ble-throughput</link><description>Hi, 
 I have a question regarding our approach to achieving high throughput UART transmission over BLE. 
 The protoboards we are currently testing have BL654 modules from Laird which use the nRF52840 SoC with the following setup: - nRF5SDK v16.0.0 - Soft</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Sep 2020 21:07:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60624/maximizing-uart-over-ble-throughput" /><item><title>RE: Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/thread/269740?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 21:07:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a8e5e04-3f45-4a07-9e5d-165e86389c20</guid><dc:creator>cachro2</dc:creator><description>&lt;p&gt;Thanks!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/thread/260149?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 12:48:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dcd7589-048e-411f-8222-4f7bf295417b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Robert,&lt;/p&gt;
&lt;p&gt;It is true that this could give a BLE speed of about 1.3MBPS under the same conditions, such as distance and environment, as your ble_att_mtu_throughput test. However, you should also set the connection interval to what you used in that test. I don&amp;#39;t know what it is, but please check that it is set to be equal both on the peripheral and the central. Depending on what SDK version you use, this is done in either main.c or sdk_config.h on the central, and the main.c file on the peripheral. Let me know what SDK version you use if you can&amp;#39;t find it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The key to a high throughput in BLE is to use the entire MTU when you send packets. I don&amp;#39;t know how you do that now, but shorter packets will mean higher overhead/payload ratio, and hence a lower throughput.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please check out the attached throughput demo over NUS. I don&amp;#39;t remember exactly, but you need to push button 3 or 4 on one of the devices to start the transmission of data. Monitor the RTT log on both devices to check the throughput. You should be able to tell from the source code what the different buttons do.&lt;/p&gt;
&lt;p&gt;Unzip in SDK16, so they have the similar paths as the examples in the SDK.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d3e38e9ac06841b2918dcc850f783ea2/nus_5F00_throughput.zip"&gt;devzone.nordicsemi.com/.../nus_5F00_throughput.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/thread/260025?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2020 05:13:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69427d7a-e698-4908-b808-7cb7423a014e</guid><dc:creator>cachro2</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have tested the&amp;nbsp;&lt;span&gt;&lt;em&gt;ble_app_att_mtu&lt;/em&gt; code and achieved 1327 kbps as referenced in the link sent.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, I am having difficulty achieving increased throughput using the&amp;nbsp;&lt;em&gt;ble_app_uart&lt;/em&gt; project. I diff&amp;#39;d the projects and reviewed&amp;nbsp;the code extensively.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here are the few modifications I have made for&amp;nbsp;&lt;em&gt;ble_app_uart:&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;pre class="ui-code" data-mode="text"&gt;BLE_APP_UART
--------------------------------------------------------
# sdk_config.h
--------------------------------------------------------
// &amp;lt;i&amp;gt; Requested BLE GAP data length to be negotiated.
#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
#endif
--------------------------------------------------------
// &amp;lt;o&amp;gt; NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. 
#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#endif

--------------------------------------------------------
# main.c
--------------------------------------------------------
#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(50, UNIT_1_25_MS)             /**&amp;lt; Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(50, UNIT_1_25_MS)             /**&amp;lt; Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
--------------------------------------------------------
static uint16_t   m_ble_nus_max_data_len = NRF_SDH_BLE_GATT_MAX_MTU_SIZE - 3;       /**&amp;lt; Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
--------------------------------------------------------
    case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
    {
        NRF_LOG_DEBUG(&amp;quot;PHY update request.&amp;quot;);
        ble_gap_phys_t const phys =
        {
            .rx_phys = BLE_GAP_PHY_2MBPS,
            .tx_phys = BLE_GAP_PHY_2MBPS,
        };
        err_code = sd_ble_gap_phy_update(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, &amp;amp;phys);
        APP_ERROR_CHECK(err_code);
    } break;






&lt;/pre&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And here are the few modifications I have made for &lt;em&gt;ble_app_uart_c&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;BLE_APP_UART_C
--------------------------------------------------------
# sdk_config.h
--------------------------------------------------------
// &amp;lt;i&amp;gt; Requested BLE GAP data length to be negotiated.
#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
#endif
--------------------------------------------------------
// &amp;lt;o&amp;gt; NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. 
#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#endif

--------------------------------------------------------
# main.c
--------------------------------------------------------
static uint16_t m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - OPCODE_LENGTH - HANDLE_LENGTH; /**&amp;lt; Maximum length of data (in bytes) that can be transmitted to the peer by the Nordic UART service module. */
--------------------------------------------------------


&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The peripheral device should now be configured for ATT MTU = 247,&amp;nbsp;GAP data length = 251 and a connection interval of 50ms with the 2M Phy. Since the peripheral device is sending the big payload, I assume that I do not have modify ble_app_uart_c as extensively&amp;nbsp;since the peripheral sets these parameters. I believe this is why I could not find where the connection interval or PHY was set in the central firmware.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, when I test this and use RealTerm to send a 87kB binary file over UART at 230400 baud from the peripheral device, it takes ~38 seconds to send (18kbps). Much too slow.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It should actually take&amp;nbsp;about 5 seconds since:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;UART over BLE transmit time = 87kB of data sent at 230400 baud = 3.77 seconds + UART overhead = 4-5 seconds&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am assuming that BLE transmission speed (1327 kbps) &amp;gt;&amp;gt; UART transmission (230.4 kbps) therefore we should not get any buffers overflowing on BLE modules during transmission.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Your help is much appreciated.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Robert&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/thread/246598?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 16:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20e1632f-1881-4bcc-be8a-684d8a8e395a</guid><dc:creator>cachro2</dc:creator><description>&lt;p&gt;Thank you,&amp;nbsp;will test and report results asap.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Maximizing UART over BLE throughput</title><link>https://devzone.nordicsemi.com/thread/246551?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 13:50:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07932ad2-1980-40a4-9787-b30d375fd292</guid><dc:creator>bjorn-spockeli</dc:creator><description>[quote user=""]We have tested &amp;quot;ble_app_att_mtu_throughput&amp;quot; and have been able to achieve ~340Kbps between two nrf52840 DK boards with the default configuration as listed &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fble_sdk_app_att_mtu.html"&gt;here&lt;/a&gt;. This is a reasonable speed using 2Mbps PHY. Of course we were hoping to achieve maximum throughput (~1Mbps) line-of-sight using UART profile&amp;nbsp;as was done in the nRF52 image transfer &lt;a href="https://github.com/NordicPlayground/nrf52-ble-image-transfer-demo"&gt;demo&lt;/a&gt;.[/quote]
&lt;p&gt;&amp;nbsp;The default GAP data length in the Throughput example is 27, so oncreasing the GAP data length should result in a higher throughput.&lt;/p&gt;
[quote user=""]Not being a BLE expert myself, I would likely proceed by diff&amp;#39;ing the projects, (ble_app_att_mtu) and (ble_app_uart), and&amp;nbsp;modifying ble_app_uart configuration to achieve a higher throughput. Is this a good approach? Assuming the&amp;nbsp;setup which was described above, what do you suspect is the highest&amp;nbsp;possible throughput using the Nordic UART profile?&amp;nbsp;[/quote]
&lt;p&gt;Yes, comparing the two projects and using the same settings as the Throughput example in the ble_app_uart example is a good approach.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The ble_app_uart example uses notifications to send the data from the peripheral to the central. Looking at the&amp;nbsp;&lt;a title="Bluetooth Low Energy data throughput" href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html?cp=4_6_3_0_16"&gt;Bluetooth Low Energy data throughput&lt;/a&gt;&amp;nbsp;in the S140 SoftDevice Specification, the highest achievable throughput with a single connection, &amp;nbsp;ATT MTU = 247,&amp;nbsp;&lt;span&gt;GAP data length = 251 and a connection interval of 50ms is 1327kbps with the 2M Phy and 702,8kbps with the 1M Phy&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d3e38e9ac06841b2918dcc850f783ea2/pastedimage1587735969011v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>