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");
}
}
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");
}
}
CONFIG_BT_AUTO_PHY_UPDATE=n CONFIG_BT_USER_PHY_UPDATE=y
... 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 ...
... 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: