This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use 2MBPS mode to get max throughput

I am working on nrf52832 and SDK V15_3 and Softdevice S132 . I want to enable 2MBPS mode to achieve maximum throughput. I have checked different links in nordic devzone but , nothing is working in my case. i have attached some code snippet here.

2. When i set  att mtu sie = 160 , the throughput is getting 52KBytesPS at connection interval 7.5. But when i increase to mtu size 240 , getting throughput less than the previous. When  i sending data through characteristics, 6times getting error =19 and one time it will success, thats why reduce the throughput , i dont know whys its getting error 19 most of the time.

void advertising_init(void)
{
    ret_code_t             err_code;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance      = true;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.advdata.uuids_complete.p_uuids  = m_adv_uuids;

    init.config.ble_adv_primary_phy      = BLE_GAP_PHY_1MBPS;
    init.config.ble_adv_secondary_phy    = BLE_GAP_PHY_2MBPS;
    init.config.ble_adv_extended_enabled = true;
    init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_whitelist_enabled = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}
//---------------------------------------------------------------------------------

//also enabled ext mode in main

    gatt_mtu_set(m_test_params.att_mtu);
    conn_evt_len_ext_set(m_test_params.conn_evt_len_ext_enabled);

Parents
  • Hello,

    To change to 2MBPS, you must request this, e.g. in your BLE_GAP_EVT_CONNECTED event. Add something like this in the event:

            case BLE_GAP_EVT_CONNECTED:
                ...
                // The already included stuff.
                ...
                
                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->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
                
                break;
            
            case ...:

    Then you should see something like this in the log:

    <info> app_timer: RTC: initialized.
    <info> app: Debug logging for UART over RTT started.
    <info> app: Connected to 76:C9:A8:D5:F6:74
    <info> app: Data len is set to 0xB6(182)
    <info> app: Phy Updated. TX: 2, RX: 2

    If you want to, you can try the attached project in SDK16.0.0. Unzip it so that the nus_throughput is located in the same folder as ble_central and ble_peripheral.

    You can either test the ble_app_uart example either with a phone, or together with the ble_app_uart_c example.


    nus_throughput.zip

    NB: to start the transmission, you must press button 4 on the DK, and you can monitor the throughput in the log.

    Regarding question 2:

    The throughput of a link is a bit complex. It may be that the total average you were able to transmit was higher before you increased the MTU, because you were able to queue e.g. 2x packets with size 160Bytes, but only one with size 240 per connection interval, reducing the total throughput from 320 bytes to 240 bytes. 

    Actually, if you want to increase the throughput the best thing is to increase the connection intevral and the connection event length and the MTU. However, when the central is a phone, they typically insist to using one specific connection interval (and it may be different from what you set as the preferred connection interval in the peripheral).

    You can test the throughput with different settings if you have two DKs by using the ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput example.

    Best regards,

    Edvin

Reply
  • Hello,

    To change to 2MBPS, you must request this, e.g. in your BLE_GAP_EVT_CONNECTED event. Add something like this in the event:

            case BLE_GAP_EVT_CONNECTED:
                ...
                // The already included stuff.
                ...
                
                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->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
                
                break;
            
            case ...:

    Then you should see something like this in the log:

    <info> app_timer: RTC: initialized.
    <info> app: Debug logging for UART over RTT started.
    <info> app: Connected to 76:C9:A8:D5:F6:74
    <info> app: Data len is set to 0xB6(182)
    <info> app: Phy Updated. TX: 2, RX: 2

    If you want to, you can try the attached project in SDK16.0.0. Unzip it so that the nus_throughput is located in the same folder as ble_central and ble_peripheral.

    You can either test the ble_app_uart example either with a phone, or together with the ble_app_uart_c example.


    nus_throughput.zip

    NB: to start the transmission, you must press button 4 on the DK, and you can monitor the throughput in the log.

    Regarding question 2:

    The throughput of a link is a bit complex. It may be that the total average you were able to transmit was higher before you increased the MTU, because you were able to queue e.g. 2x packets with size 160Bytes, but only one with size 240 per connection interval, reducing the total throughput from 320 bytes to 240 bytes. 

    Actually, if you want to increase the throughput the best thing is to increase the connection intevral and the connection event length and the MTU. However, when the central is a phone, they typically insist to using one specific connection interval (and it may be different from what you set as the preferred connection interval in the peripheral).

    You can test the throughput with different settings if you have two DKs by using the ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput example.

    Best regards,

    Edvin

Children
No Data
Related