How to enable BLE 2MBPS

Hello,

I'm trying to enable 2MBPS using 2 nRF52840-DK. I'm using SDK17 examples with Segger Embedded Studio. The peripheral uses the ble_app_uart example. The central uses ble_app_uart_c example.

I was able to make them work as default at 1MBPS, but I have problems making them work at 2MBPS. I saw a similar issue at another post but that didn't help me to resolve my issue.

I did the following changes on the central 2MBPS, in ble_evt_handler:

case BLE_GAP_EVT_PHY_UPDATE_REQUEST:
{
    printf("PHY update request.");
    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;

In the peripheral, I made these changes:

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;

    ble_gap_phys_t m_test_params;
    m_test_params.tx_phys = BLE_GAP_PHY_2MBPS;
    m_test_params.rx_phys = BLE_GAP_PHY_2MBPS;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            printf("Connected\r\n");
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
            err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
            APP_ERROR_CHECK(err_code);
            // Add these lines for 2MBPS
            err_code = sd_ble_gap_phy_update(m_conn_handle, &m_test_params);
            APP_ERROR_CHECK(err_code);
            break;

        case BLE_GAP_EVT_PHY_UPDATE:
            printf("BLE_GAP_EVT_PHY_UPDATE\r\n");
           break;

..........

}

After the changes, they still operate at 1MBPS. Even though I see the printout BLE_GAP_EVT_PHY_UPDATE on the peripheral, as well a message .'PHY update request' on the central device, showing they are supposed to update the PHY to 2MBPS.

I wonder what else needs to be done. I appreciate any help to resolve the issue.

Parents
  • Hi vn2000,

    Could you go deeper into the event structure and get the details of BLE_GAP_EVT_PHY_UPDATE?

    You can get from the fields of p_ble_evt->gap.evt.phy_update.

    Reference: infocenter.nordicsemi.com/.../structble__gap__evt__phy__update__t.html

    Hieu

  • Hi Hieu,

    I made the following changes in BLE_GAP_EVT_PHY_UPDATE.

    ble_gap_evt_t const * const p_gap = &p_ble_evt->evt.gap_evt;

    case BLE_GAP_EVT_PHY_UPDATE:
        printf("Received BLE_GAP_EVT_PHY_UPDATE (RX:%d, TX:%d, status:%d)",
                p_gap->params.phy_update.rx_phy,
                p_gap->params.phy_update.tx_phy,
                p_gap->params.phy_update.status);
        break;

    I see the output:
    Received BLE_GAP_EVT_PHY_UPDATE (RX:2, TX:2, status:0).

    So it looks like the RX and TX PHY are changed to 2MBPS. But why don't I get a speed change? Could it be my test program didn't work correctly. Do you recommend any test program that tests the 2MBPS throughput?

    Thanks.

  • Hi vn2000,

    Yes, the path to the example and a step-by-step guide to perform the test are all include in the link in my previous answer Slight smile

  • Hi Hieu,

    I was tied up by another task last couple days. Now I compiled and downloaded both boards and I encountered some problems.

    On the tester board, I pushed the button 3 and I see this:

    throughput example:~$ config print
    ==== Current test configuration ====
    Board role: tester
    ATT MTU size: 247
    Data length: 27
    Connection interval: 6 units
    Connection length ext: on
    Preferred PHY: 2 Mbps
    GAP event length: 400

    On the dummy board, I pushed the button 4 and I see this:

    throughput example:~$ config print
    ==== Current test configuration ====
    Board role: dummy
    ATT MTU size: 247
    Data length: 251
    Connection interval: 6 units
    Connection length ext: on
    Preferred PHY: 2 Mbps
    GAP event length: 400

    The Data length are different. Do they need to be equal?

    When I type 'run', the dummy board complained:

    'Wrong board setup!'

    Do you have any suggestion?

  • Welcome back vn2000,

    The Data Length doesn't seem to have to be equal.
    I reviewed the source code and see that the example would complain "Wrong board setup!" if you call run from the dummy/responder board.
    Please command "run" on the tester board. 

    Here is my log for your reference.

  • Hello Hieu,

    I can make it work now. The only thing I have to set the data length to 251 on the tester. I don't know why it was not set to 251 as default like the dummy board. I can fix it in the firmware.

    Anyway thank you for your help. Nordic is the best.

  • Hi vn2000,

    vn2000 said:
    I don't know why it was not set to 251 as default like the dummy board.

    They are probably different configurations for different test cases. You could see our publicize throughput numbers at the following link, where different configurations also result in different results:

    https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html

    That said, BLE devices can have different data length when they are not connected. However, once connected, they should agree on the same data length during connection parameters update. It could be that the example is setup to not allow data length update, in order to ensure the test case is fixed. You should be able to find the details in the example's code.

    It's a bit odd that my test didn't encounter the same issue. Perhaps because I used the precompiled hex files directly. I hope things work well for you now.

    vn2000 said:
    Nordic is the best.

    Thank you for the kind words.

Reply
  • Hi vn2000,

    vn2000 said:
    I don't know why it was not set to 251 as default like the dummy board.

    They are probably different configurations for different test cases. You could see our publicize throughput numbers at the following link, where different configurations also result in different results:

    https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html

    That said, BLE devices can have different data length when they are not connected. However, once connected, they should agree on the same data length during connection parameters update. It could be that the example is setup to not allow data length update, in order to ensure the test case is fixed. You should be able to find the details in the example's code.

    It's a bit odd that my test didn't encounter the same issue. Perhaps because I used the precompiled hex files directly. I hope things work well for you now.

    vn2000 said:
    Nordic is the best.

    Thank you for the kind words.

Children
Related