<?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>Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40322/incease-ble-throughput-in-nrf51822</link><description>Hi guys, 
 I am developing a application and I want to increase the BLE throughput to atleast 1.3kB/s. 
 I have already read this thread: https://devzone.nordicsemi.com/f/nordic-q-a/12935/how-to-transmit-6-packets-in-s130-uart-central 
 and this thread</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 14 Nov 2018 11:37:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40322/incease-ble-throughput-in-nrf51822" /><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/157271?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 11:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7e4f372-f7b7-4a33-85c1-105d5938a3ae</guid><dc:creator>Hust</dc:creator><description>&lt;p&gt;Very helpful. Thank you very much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/157261?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 11:04:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b5a82e5-c6c9-4fb2-baf6-69c18390e7a2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Unfortunately, it&amp;#39;s not possible to get more packets per event if you use write requests. That said, you could consider using a combination of these two to both achieve higher throughput and acknowledgment at the application layer.&amp;nbsp;Possibly something similar to the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/lib_dfu_transport_ble.html?cp=4_0_0_3_5_2_2"&gt;BLE DFU transport&lt;/a&gt;&amp;nbsp;where&amp;nbsp;we have one&amp;nbsp;&amp;nbsp;&amp;quot;control point&amp;quot; characteristic for commmands and another characteristic for receiving the data. Then you could send write requests to the control point for&amp;nbsp; enabling reception of x number of bytes on the data characteristic.&amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/157222?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 08:15:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1240566f-6d23-4ef5-afa8-1bb12f97fdd1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I didn&amp;#39;t notice that you were sending write requests before now. Write requests are significantly slower compared to Write commands as the requests need to be acknowledged by server at the application layer before next write can be requested (both are acknowledged at the link layer). In other words, you will only get one request per connection event. So I&amp;#39;d recommend to use write command to improve throughput.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="DatHust"]&lt;p&gt;&lt;/p&gt;&lt;p&gt;What do you mean here? How can I do it? Please be patient with me.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I could have been more clear.&amp;nbsp;I have limited experienced with app development on the iphone, but the &amp;quot;write&amp;quot; API should be asynchronous -&amp;nbsp;write packets are added to an output queue by the write API and later de-queued by the BT stack when the packet is sent on air. So I meant that you should&amp;nbsp;make sure to&amp;nbsp;have multiple packets in the output queue in order to allow the stack to send multiple packets per connection event.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/157195?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 03:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50b794ad-6266-49d0-b650-e67d45eaf4e9</guid><dc:creator>Hust</dc:creator><description>&lt;p&gt;Thank you very much, I have achieved it. Turn out it is because on the mobile phone, it is in write with response mode, so it can not achieve multiple packets per interval connection. When I switched to write without response, it&amp;#39;s okay now.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But the thing is, because of the consistency and security, I need to keep the mode write with response, is there any way else I still can achieve this multiple packets?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you very much for your help, I really appreciate it, it&amp;#39;s very valuable to me.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/157000?ContentTypeID=1</link><pubDate>Tue, 13 Nov 2018 08:20:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b3aea32-f9d0-4af8-a2b7-75662a2b7d7c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Looks like you have correctly enabled high BW mode for the connection now. To maximize throughput it is also important to keep the notification/write queue full, are you doing that in your code? Attached is the project I used for test (modified ble_app_uart example in sdk 12.3.0).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Steps to test:&lt;/p&gt;
&lt;p&gt;1. unzip zip file and copy folder to&amp;nbsp;nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral&lt;/p&gt;
&lt;p&gt;2. Build and flash the FW&lt;/p&gt;
&lt;p&gt;3. Connect to the peripheral with your iphone and enable notifications&lt;/p&gt;
&lt;p&gt;4. Open a serial client (Tera term,etc ), open the Jlink virtual com port, set baudrate to 115200, then transfer a larger chunk of data. A file for instance.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;5. Observe the packet transfer with the sniffer to determine the number of packets per event. The number of packets can be 1-7 depending on phone.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5eda43ffcc1645b0b55eefeabd02af54/ble_5F00_app_5F00_uart_5F00_mod.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart_5F00_mod.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I used an&amp;nbsp;Ellisys sniffer, but it&amp;#39;s not required for determining the number of packets per event.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/156992?ContentTypeID=1</link><pubDate>Tue, 13 Nov 2018 07:14:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5484452c-9351-4a20-b95d-312d8af06dc0</guid><dc:creator>Hust</dc:creator><description>&lt;p&gt;Hi Vidar Berg,&lt;/p&gt;
&lt;p&gt;Thank you very much for your response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did what you said and here is what it looks like in ble_stack_init();&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

	// Initialize SoftDevice.
	SOFTDEVICE_HANDLER_INIT(&amp;amp;clock_lf_cfg, NULL);

	ble_enable_params_t ble_enable_params;
	ble_conn_bw_counts_t conn_bw_counts = {
		.tx_counts = {.high_count = 1, .mid_count = 0, .low_count = 0},
		.rx_counts = {.high_count = 1, .mid_count = 0, .low_count = 0}};
	

	softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
										 PERIPHERAL_LINK_COUNT,
										 &amp;amp;ble_enable_params);
	ble_enable_params.common_enable_params.p_conn_bw_counts = &amp;amp;conn_bw_counts;

	// Enable BLE stack.
	softdevice_enable(&amp;amp;ble_enable_params);

	// Subscribe for BLE events.
	softdevice_ble_evt_handler_set(ble_evt_dispatch);

	softdevice_sys_evt_handler_set(sys_evt_dispatch);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;inside softdevice_handler: here is what the default config function looks like:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t softdevice_enable_get_default_config(uint8_t central_links_count,
                                              uint8_t periph_links_count,
                                              ble_enable_params_t * p_ble_enable_params)
{
    memset(p_ble_enable_params, 0, sizeof(ble_enable_params_t));
    p_ble_enable_params-&amp;gt;common_enable_params.vs_uuid_count   = 2;
    p_ble_enable_params-&amp;gt;gatts_enable_params.attr_tab_size    = SOFTDEVICE_GATTS_ATTR_TAB_SIZE;
    p_ble_enable_params-&amp;gt;gatts_enable_params.service_changed  = SOFTDEVICE_GATTS_SRV_CHANGED;
    p_ble_enable_params-&amp;gt;gap_enable_params.periph_conn_count  = periph_links_count;
    p_ble_enable_params-&amp;gt;gap_enable_params.central_conn_count = central_links_count;
    if (p_ble_enable_params-&amp;gt;gap_enable_params.central_conn_count != 0)
    {
        p_ble_enable_params-&amp;gt;gap_enable_params.central_sec_count  = SOFTDEVICE_CENTRAL_SEC_COUNT;
    }

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And here is the result I got when I use sniffer to see what happen:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1542092733989v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;as far as I understand, delta time is the time between 2 packets and here I got 27ms, which is pretty much what I expected when I set interval connection is 30 and using iPhone which have interval connection is 24 after negotiation.&lt;/p&gt;
&lt;p&gt;More Data mean there is more packet in that interval, so base on this, I assume most of the time there is only 1 packet per interval connection? So basically it&amp;#39;s not work?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;May I ask is this because I set sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &amp;amp;ble_opt); inside the ble_advertising_start();? Where should I put those code then?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t ble_advertising_start(ble_adv_mode_t advertising_mode)
{
    uint32_t             err_code;
    ble_gap_adv_params_t adv_params;

    m_adv_mode_current = advertising_mode;

    // Verify if there are any pending flash operations. If so, delay starting advertising until
    // the flash operations are complete.
    if(flash_access_in_progress())
    {
        m_advertising_start_pending = true;
        return NRF_SUCCESS;
    }

    ADV_LOG(&amp;quot;[ADV]: no flash operations in progress, prepare advertising.\r\n&amp;quot;);
    // Fetch the peer address.
    ble_advertising_peer_address_clear();

    if (  ((m_adv_modes_config.ble_adv_directed_enabled)      &amp;amp;&amp;amp; (m_adv_mode_current == BLE_ADV_MODE_DIRECTED))
        ||((m_adv_modes_config.ble_adv_directed_slow_enabled) &amp;amp;&amp;amp; (m_adv_mode_current == BLE_ADV_MODE_DIRECTED))
        ||((m_adv_modes_config.ble_adv_directed_slow_enabled) &amp;amp;&amp;amp; (m_adv_mode_current == BLE_ADV_MODE_DIRECTED_SLOW))
       )
    {
        if (m_evt_handler != NULL)
        {
            m_peer_addr_reply_expected = true;
            m_evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST);
        }
        else
        {
            m_peer_addr_reply_expected = false;
        }
    }

    // If a mode is disabled, continue to the next mode. I.e fast instead of direct, slow instead of fast, idle instead of slow.
    if (  (m_adv_mode_current == BLE_ADV_MODE_DIRECTED)
        &amp;amp;&amp;amp;(!m_adv_modes_config.ble_adv_directed_enabled || !peer_address_exists(m_peer_address.addr)))
    {
        m_adv_mode_current = BLE_ADV_MODE_DIRECTED_SLOW;
    }
    if (  (m_adv_mode_current == BLE_ADV_MODE_DIRECTED_SLOW)
        &amp;amp;&amp;amp;(!m_adv_modes_config.ble_adv_directed_slow_enabled || !peer_address_exists(m_peer_address.addr)))
    {
        m_adv_mode_current = BLE_ADV_MODE_FAST;
    }
    if (!m_adv_modes_config.ble_adv_fast_enabled &amp;amp;&amp;amp; m_adv_mode_current == BLE_ADV_MODE_FAST)
    {
        m_adv_mode_current = BLE_ADV_MODE_SLOW;
    }
    if (!m_adv_modes_config.ble_adv_slow_enabled &amp;amp;&amp;amp; m_adv_mode_current == BLE_ADV_MODE_SLOW)
    {
        m_adv_mode_current = BLE_ADV_MODE_IDLE;
        m_adv_evt          = BLE_ADV_EVT_IDLE;
    }

    // Fetch the whitelist.
    if (   (m_evt_handler != NULL)
        &amp;amp;&amp;amp; (m_adv_mode_current == BLE_ADV_MODE_FAST || m_adv_mode_current == BLE_ADV_MODE_SLOW)
        &amp;amp;&amp;amp; (m_adv_modes_config.ble_adv_whitelist_enabled)
        &amp;amp;&amp;amp; (!m_whitelist_temporarily_disabled))
    {
        m_whitelist_reply_expected = true;
        m_evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);
    }
    else
    {
        m_whitelist_reply_expected = false;
    }

    // Initialize advertising parameters with default values.
    memset(&amp;amp;adv_params, 0, sizeof(adv_params));

    adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
    adv_params.p_peer_addr = NULL;
    adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    adv_params.p_whitelist = NULL;

    // Set advertising parameters and events according to selected advertising mode.
    switch (m_adv_mode_current)
    {
        case BLE_ADV_MODE_DIRECTED:
            ADV_LOG(&amp;quot;[ADV]: Starting direct advertisement.\r\n&amp;quot;);
            adv_params.p_peer_addr = &amp;amp;m_peer_address; // Directed advertising.
            adv_params.type        = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND;
            adv_params.timeout     = 0;
            adv_params.interval    = 0;
            m_adv_evt              = BLE_ADV_EVT_DIRECTED;
            break;

        case BLE_ADV_MODE_DIRECTED_SLOW:
            ADV_LOG(&amp;quot;[ADV]: Starting direct advertisement.\r\n&amp;quot;);
            adv_params.p_peer_addr = &amp;amp;m_peer_address; // Directed advertising.
            adv_params.type        = BLE_GAP_ADV_TYPE_ADV_DIRECT_IND;
            adv_params.timeout     = m_adv_modes_config.ble_adv_directed_slow_timeout;
            adv_params.interval    = m_adv_modes_config.ble_adv_directed_slow_interval;
            m_adv_evt              = BLE_ADV_EVT_DIRECTED_SLOW;
            break;

        case BLE_ADV_MODE_FAST:
            adv_params.timeout  = m_adv_modes_config.ble_adv_fast_timeout;
            adv_params.interval = m_adv_modes_config.ble_adv_fast_interval;

            if (   whitelist_has_entries(&amp;amp;m_whitelist)
                &amp;amp;&amp;amp; m_adv_modes_config.ble_adv_whitelist_enabled
                &amp;amp;&amp;amp; !m_whitelist_temporarily_disabled)
            {
                adv_params.fp          = BLE_GAP_ADV_FP_FILTER_CONNREQ;
                adv_params.p_whitelist = &amp;amp;m_whitelist;
                m_advdata.flags        = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
                err_code               = ble_advdata_set(&amp;amp;m_advdata, NULL);
                VERIFY_SUCCESS(err_code);

                m_adv_evt = BLE_ADV_EVT_FAST_WHITELIST;
                ADV_LOG(&amp;quot;[ADV]: Starting fast advertisement with whitelist.\r\n&amp;quot;);
            }
            else
            {
                m_adv_evt = BLE_ADV_EVT_FAST;
                ADV_LOG(&amp;quot;[ADV]: Starting fast advertisement.\r\n&amp;quot;);
            }
            break;

        case BLE_ADV_MODE_SLOW:
            adv_params.interval = m_adv_modes_config.ble_adv_slow_interval;
            adv_params.timeout  = m_adv_modes_config.ble_adv_slow_timeout;

            if (   whitelist_has_entries(&amp;amp;m_whitelist)
                &amp;amp;&amp;amp; m_adv_modes_config.ble_adv_whitelist_enabled
                &amp;amp;&amp;amp; !m_whitelist_temporarily_disabled)
            {
                adv_params.fp          = BLE_GAP_ADV_FP_FILTER_CONNREQ;
                adv_params.p_whitelist = &amp;amp;m_whitelist;
                m_advdata.flags        = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
                err_code               = ble_advdata_set(&amp;amp;m_advdata, NULL);
                VERIFY_SUCCESS(err_code);

                m_adv_evt = BLE_ADV_EVT_SLOW_WHITELIST;
                ADV_LOG(&amp;quot;[ADV]: Starting slow advertisement with whitelist.\r\n&amp;quot;);
            }
            else
            {
                m_adv_evt = BLE_ADV_EVT_SLOW;
                ADV_LOG(&amp;quot;[ADV]: Starting slow advertisement.\r\n&amp;quot;);
            }
            break;

        default:
            break;
    }
    if (m_adv_mode_current != BLE_ADV_MODE_IDLE)
    {
    ble_opt_t ble_opt;
    ble_common_opt_conn_bw_t conn_bw;
    memset(&amp;amp;conn_bw, 0x00, sizeof(conn_bw));
    memset(&amp;amp;ble_opt, 0x00, sizeof(ble_opt));

    // if this set to mid this will work but setting it to high will not
    conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_HIGH;
    conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_HIGH;
    // conn_bw.conn_bw.conn_bw_rx = BLE_CONN_BW_MID; // conn_bw.conn_bw.conn_bw_tx = BLE_CONN_BW_MID;
    conn_bw.role = BLE_GAP_ROLE_CENTRAL;

    // gap option is missing?
    ble_opt.common_opt.conn_bw = conn_bw;
		NRF_LOG_PRINTF(&amp;quot;sd_ble_opt_set&amp;quot;);
    sd_ble_opt_set(BLE_COMMON_OPT_CONN_BW, &amp;amp;ble_opt);
        err_code = sd_ble_gap_adv_start(&amp;amp;adv_params);
        VERIFY_SUCCESS(err_code);
    }
    if (m_evt_handler != NULL)
    {
        m_evt_handler(m_adv_evt);
    }

    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And what is the software that you use to determine the number of packets per connection interval?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incease BLE throughput in nrf51822</title><link>https://devzone.nordicsemi.com/thread/156940?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 15:20:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:890c84ad-c7df-4602-a4df-9d7695e588c2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;ble_enable_params is &amp;quot;memset&amp;quot; in&amp;nbsp;softdevice_enable_get_default_config() so your settings&amp;nbsp;did not get applied. Should work if you place &amp;quot;ble_enable_params.common_enable_params.p_conn_bw_counts = &amp;amp;conn_bw_counts;&amp;quot;&amp;nbsp; after softdevice_enable_get_default_config() in ble_stack_init.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried with the same settings here and got 7 packets per connection @30&amp;nbsp;ms intervals with an iphone 7.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5eda43ffcc1645b0b55eefeabd02af54/pastedimage1542035980589v1.png" alt=" " /&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></channel></rss>