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 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,

    An even better way to confirm whether you have 2M PHY is to get a sniffer trace. You can use the nRF Sniffer for that.

    The Throughput Example is created for throughput testing purpose. Would you like to give that a try?
    Here is its documentation: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_att_mtu.html.

    Hieu

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

Related