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 Reply Children
  • Hi Hieu,

    I want to make sure I'm using the right example you suggested. I'm using SDK V17;

    \nRF5_SDK\V17\examples\ble_central_and_peripheral\experimental\ble_app_att_mtu_throughput

    So I will use this same example on both central and peripheral device?

  • 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.

Related