unable to change BLE PHY from 1M to 2M on nrf52840/5340DK

Hi there,

I am writing code to set my BLE PHY throughput from 1M to 2M when my device establishes a connection; my code works when I connect to my nRF52840 dongle from a phone (through the nRF Connect App as well as regular BLE connection), but not from my Windows 10, Windows 11, or Mac computer. The BLE examples provided by Nordic work fine on my computer, so I think this is a problem with my code or configuration settings rather than something with Windows or Mac.

I am running the following function in my BLE on_connected() event:

void update_phy(struct bt_conn *conn) {

    int err;
    struct bt_conn_le_phy_param phy_param = {
        .options = BT_CONN_LE_PHY_OPT_NONE,
        .pref_tx_phy = BT_GAP_LE_PHY_2M,
        .pref_rx_phy = BT_GAP_LE_PHY_2M
    };

    err = bt_conn_le_phy_update(conn, &phy_param);
    if (err) {
        NUS_Send("bt_conn_le_phy_update() returned %d \n", err);
    } else {
        NUS_Send("PHY update initiated \n");
    }
}
Then I run the following in the le_phy_update() callback:
void on_le_phy_updated(struct bt_conn *conn, struct bt_conn_le_phy_info *param)
{
    NUS_Send("PHY new value is %d \n", param->tx_phy);
    // PHY Updated
    if (param->tx_phy == BT_CONN_LE_TX_POWER_PHY_1M) {
        NUS_Send("PHY TX updated. New PHY: 1M \n");
    } else if (param->tx_phy == BT_CONN_LE_TX_POWER_PHY_2M) {
        NUS_Send("PHY TX updated. New PHY: 2M \n");
    } else if (param->tx_phy == BT_CONN_LE_TX_POWER_PHY_CODED_S8) {
        NUS_Send("PHY TX updated. New PHY: Long Range \n");
    }
}
When I check through the serial terminal the value remains as BT_CONN_LE_TX_POWER_PHY_1M instead of BT_CONN_LE_TX_POWER_PHY_2M. Just to be sure, I have also set the following in my project .config (I also tried with CONFIG_BT_AUTO_PHY_UPDATE set to y):
CONFIG_BT_AUTO_PHY_UPDATE=n
CONFIG_BT_USER_PHY_UPDATE=y
 
Running Wireshark I get the following with my phone connection:
...
118457 561.688392 Slave_0xa5e9a0cb Master_0xa5e9a0cb LE LL 29 Control Opcode: LL_PHY_REQ
118458 561.688646 Master_0xa5e9a0cb Slave_0xa5e9a0cb LE LL 26 Empty PDU
118459 561.777612 Master_0xa5e9a0cb Slave_0xa5e9a0cb LE LL 31 Control Opcode: LL_PHY_UPDATE_IND
118460 561.777882 Slave_0xa5e9a0cb Master_0xa5e9a0cb SMP 95 Rcvd Pairing Public Key
118461 561.778664 Master_0xa5e9a0cb Slave_0xa5e9a0cb LE LL 26 Empty PDU
118462 561.867612 Master_0xa5e9a0cb Slave_0xa5e9a0cb SMP 47 Sent Pairing Random
118463 561.868010 Slave_0xa5e9a0cb Master_0xa5e9a0cb LE LL 26 Empty PDU
118464 561.957613 Master_0xa5e9a0cb Slave_0xa5e9a0cb LE LL 26 Empty PDU
...
Looks good... with my computer connection:
...
322 1.824729 Slave_0x444e8168 Master_0x444e8168 LE LL 29 Control Opcode: LL_PHY_REQ
323 1.824984 Master_0x444e8168 Slave_0x444e8168 ATT 33 Sent Exchange MTU Response, Server Rx MTU: 527
324 1.944445 Master_0x444e8168 Slave_0x444e8168 LE LL 28 Control Opcode: LL_UNKNOWN_RSP
325 1.944690 Slave_0x444e8168 Master_0x444e8168 LE LL 26 Empty PDU
326 1.944920 Master_0x444e8168 Slave_0x444e8168 SMP 95 Sent Pairing Public Key
327 2.064447 Master_0x444e8168 Slave_0x444e8168 SMP 95 Sent Pairing Public Key
328 2.065228 Slave_0x444e8168 Master_0x444e8168 LE LL 26 Empty PDU
329 2.065458 Master_0x444e8168 Slave_0x444e8168 ATT 39 Sent Find By Type Value Request, Primary Service, Handles:
...
Notice there is a LL_UNKNOWN_RSP response on the computer. I am not sure what could be causing this problem. I do not change the PHY value anywhere else in the firmware, so I am not sure why the value remains as 1M. I have also tried on an nRF5340 DK board, no difference. Would appreciate any pointers as I think I'm missing something.
Parents
  • Hi

    Are you sure the Windows/Mac devices support other Bluetooth LE PHYs than the 1MBPS PHY? I don't think it's very normal for computers to have Bluetooth controllers/stacks that support "advanced" optional Bluetooth LE features. Have you tested this between I.E. two nRF52/53 DKs to see if you're able to get 2MBPS to work between them. Or are you saying that you can connect over 2MBPS if you use unmodified sample projects?

    Best regards,

    Simon

Reply
  • Hi

    Are you sure the Windows/Mac devices support other Bluetooth LE PHYs than the 1MBPS PHY? I don't think it's very normal for computers to have Bluetooth controllers/stacks that support "advanced" optional Bluetooth LE features. Have you tested this between I.E. two nRF52/53 DKs to see if you're able to get 2MBPS to work between them. Or are you saying that you can connect over 2MBPS if you use unmodified sample projects?

    Best regards,

    Simon

Children
  • Hi Simon,

    I am not sure how to confirm my BLE version or whether my computer supports advanced features. The firmware for my BLE adapter states "LMP 8.256", which does not appear to correspond to BLE 5.0, in which 2M PHY was introduced, so this would make sense. However I was able to set and read back a 2Mb speed on the connection (between my device and Windows) with the below BLE sample project from Nordic, which uses the same snippets of code as I posted above:

    github.com/.../blefund_less3_exer2_solution

    So I am confused on whether this is a Windows problem, or some configuration settings that I might be missing in my firmware.

Related