<?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>Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application</link><description>Hello, 
 we developed an application with a nRF52840DK as central and a custom board with a nRF52832 chip as peripheral. The peripheral sends data via NUS with a data rate of 40.8 kBit/s to the central. The code on the central is based on the ble_app_uart_c</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Mar 2021 14:10:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application" /><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/299036?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 14:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f789babb-ad76-4593-873a-07dc09519f0b</guid><dc:creator>Sigurd</dc:creator><description>[quote user="Michael01101"]But it looks promising at the moment. Thank you so much for this.[/quote]
&lt;p&gt;&amp;nbsp;Great!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Michael01101"]This are the default values of this multilink example. Do you recommend to adjust them?[/quote]
&lt;p&gt;&amp;nbsp;For optimal performance, you want to avoid scheduling conflicts on the central between scanning activity and the BLE links. Since you are using connection interval=40ms, then I think setting the scan interval to 40ms would be a good choice For the scan window, if you are connected to 1 link with NRF_SDH_BLE_GAP_EVENT_LENGTH= 10 -&amp;gt; 12.5ms, you basically have 40ms – 12.5ms= 27.5ms left for scan window, for 2 links it’s 15ms left for scan window. I assume that you are not scanning when you have 3 links connected. So easiest is then to set scan interval to 40ms, and scan window to 15ms. Scanning window/interval is in 0.625 units, so try this:&lt;/p&gt;
&lt;p&gt;NRF_BLE_SCAN_SCAN_INTERVAL 64&lt;/p&gt;
&lt;p&gt;NRF_BLE_SCAN_SCAN_WINDOW 24&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/299016?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 13:48:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db6ba116-246d-4fc4-86e7-01ea40f1f4d6</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;first of all, thank you very much for your quick reply.&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application/299003#299003"]How many peripherals is the central connected to when you see this issue?[/quote]
&lt;p&gt;Only 1. So the Central continues scanning.&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application/299003#299003"]Is the central doing scanning at the same time?[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application/299003#299003"]what is the scan window and scan interval?[/quote]
&lt;p&gt;I use this parameters:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NRF_BLE_SCAN_SCAN_INTERVAL 160
#define NRF_BLE_SCAN_SCAN_WINDOW 80&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This are the default values of this multilink example. Do you recommend to adjust them?&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application/299003#299003"]I assume that the peripheral, once connected, is no longer advertising.[/quote]
&lt;p&gt;That is correct.&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/72398/expectable-data-rates-with-nus-in-multilink-application/299003#299003"]You could try set the hvn_tx_queue_size directly[/quote]
&lt;p&gt;I add this code snippet to my project. I set the&amp;nbsp;hvn_tx_queue_size to 30 and made the required changes to the RAM parameters. (I have a lot of unused RAM)&lt;/p&gt;
&lt;p&gt;It looks like that the first data link between central and peripheral works now. But I need to do further testing to verify this (e.g. check if the&amp;nbsp;&lt;span&gt;hvn_tx_queue_size gets emptied fast enough). I will also try it with the other peripherals. I will let you know my results. But it looks promising at the moment. Thank you so much for this.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Michael&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&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: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/299003?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 13:18:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42275175-ff06-4a16-b807-0e2ba84f2b5a</guid><dc:creator>Sigurd</dc:creator><description>[quote user="Michael01101"]At the moment I am still getting a NRF_ERROR_RECOURCES error after calling ble_nus_data_send() ~20 times.[/quote]
&lt;p&gt;&amp;nbsp;How many peripherals is the central connected to when you see this issue?&lt;/p&gt;
&lt;p&gt;Is the central doing scanning at the same time? If yes, what is the scan window and scan interval? This might affect things.&lt;/p&gt;
&lt;p&gt;I assume that the peripheral, once connected, is no longer advertising.&lt;/p&gt;
&lt;p&gt;You could try set the hvn_tx_queue_size directly, and see if it improves anything, snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Function for the SoftDevice initialization.
 *
 * @details This function initializes the SoftDevice and the BLE event interrupt.
 */
static void ble_stack_init(void)
{
    ret_code_t err_code;

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);

    // Configure the BLE stack using the default settings.
    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    ble_cfg_t ble_cfg;
    memset(&amp;amp;ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.conn_cfg.conn_cfg_tag = APP_BLE_CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = 10;

    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &amp;amp;ble_cfg, ram_start);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;sd_ble_cfg_set() returned %s when attempting to set BLE_CONN_CFG_GATTS.&amp;quot;,
                      nrf_strerror_get(err_code));
    }



    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&amp;amp;ram_start);
    APP_ERROR_CHECK(err_code);

    // Register a handler for BLE events.
    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/298946?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 10:06:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c7a2701-1f05-4d78-b36b-d5634e60686e</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello Sigurd,&lt;/p&gt;
&lt;p&gt;thank you very much for your reply.&lt;/p&gt;
&lt;p&gt;I changed the &lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH to 10 on central and peripheral. I also did the required changes regarding to the ram start.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have the following settings for the connection interval on central:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// &amp;lt;o&amp;gt; NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL - Determines minimum connection interval in milliseconds. 
#ifndef NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL
#define NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL 40
#endif

// &amp;lt;o&amp;gt; NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL - Determines maximum connection interval in milliseconds. 
#ifndef NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL
#define NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL 40
#endif&lt;/pre&gt;On the peripheral I have the following parameters for the connection interval:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(40, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(40, UNIT_1_25_MS)  &lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which connection interval should I use, when I am calling the ble_nus_data_send() function every 40ms with 204 Bytes?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;At the moment I am still getting a NRF_ERROR_RECOURCES error after calling ble_nus_data_send() ~20 times. I start calling this function, when central and peripheral is connected and the MTU exchange has finished.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you please provide me some further guidance how to achieve a stable 40kBit/s data-rate between central and peripheral?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you very much in advance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Michael&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/298862?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 23:25:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c9ba85c-d1d3-4f5e-b2fa-3d144dbb76da</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Did you change the value of&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH ? If you had it at the default value of 6, then try to set it to 10.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/298344?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 11:47:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdce0cb8-f938-4168-86b7-5db604f96f6a</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thank you very much for your reply.&lt;/p&gt;
&lt;p&gt;I checked out the Throughput Example. Depending on the used parameters I can get up to 1300 kbps in a 1-to-1 connection. But when I use the ble_app_uart_c and ble_app_uart examples I can&amp;#39;t even nearly reach this data rate.&lt;/p&gt;
&lt;p&gt;I modified the ble_app_uart example that it sends 204 Bytes every 40ms by calling ble_nus_data_send(). Connection Interval is also 40ms. It runs for a few seconds, then I get&amp;nbsp;ERROR 19 [NRF_ERROR_RESOURCES] .&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So my question is:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What do I have to change in the ble_app_uart example in order to reach a data-rate of &amp;gt;40 kbps without errors?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Expectable data rates with NUS in multilink application</title><link>https://devzone.nordicsemi.com/thread/298229?ContentTypeID=1</link><pubDate>Sun, 07 Mar 2021 22:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8de36fea-1d8d-404c-a914-3b8234ed0d34</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;1. Is it&amp;nbsp;possible to achieve this data rate between each peripheral and the central?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&amp;nbsp;Yes, 40 kbit/s should be fully possible to achieve.&lt;/p&gt;
[quote user=""]2.&amp;nbsp;What are the correct connection parameters to achieve this? [/quote]
&lt;p&gt;&amp;nbsp;Well, you could probably&amp;nbsp;&lt;span&gt;achieve&amp;nbsp;&lt;/span&gt;this with many different connection parameter sets(combinations of different MTU&amp;#39;s sizes, Connection intervals, LL payload sizes, etc). But, one of the most important thing for achieving optimal performance in a multi-link setup like this is that all connections have intervals that have a common factor, as explained in&amp;nbsp;the SDS Chapter &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/multilink_scheduling/suggested_intervals_windows_s132.html"&gt;Suggested intervals and windows&lt;/a&gt;. That means for e.g. a link with 3 peripherals like this, the connection interval should not be lower than NRF_SDH_BLE_GAP_EVENT_LENGTH * 3. In the SDK, most examples uses&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH=6 (in 1.25ms units), so if you don&amp;#39;t change that parameter, you should use a connection&amp;nbsp;interval that is&amp;nbsp;minimum 22.5ms.&lt;/p&gt;
[quote user=""]3. Do you have any suggestions or tips, how to evaluate the maximum amount of peripherals properly?[/quote]
&lt;p&gt;&amp;nbsp;We have a&amp;nbsp;Throughput Example in the SDK,&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ble_sdk_app_att_mtu.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/ble_sdk_app_att_mtu.html,&lt;/a&gt;&amp;nbsp;,it&amp;#39;s only written for testing a 1-to-1 connection, but it could be a good starting point for evaluation in a multi-link setup as well. We also have some numbers in the SDS Chapter &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html"&gt;Bluetooth Low Energy data throughput&lt;/a&gt;&amp;nbsp;you can have a look at.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>