PHY update problems?

Hi

I am using the nRF54L15 DK and build a thread continueing monitor the data rate in 1 Hz, if it is lower to 800kbps I want to change to 1M; while above 800kbps I want to change to 2M. My code is:

int desired_phy = (avg_rate > 800000.0f) ? 2 : 1;

            if (desired_phy != last_phy) {
                struct bt_conn_le_phy_param *phy = 
                    (desired_phy == 2) ? &phy_2m : &phy_1m;
                int phy_err = bt_conn_le_phy_update(default_conn, phy);
                if (phy_err) {
                    LOG_WRN("PHY update failed (%d)", phy_err);
                } else {
                    last_phy = desired_phy;
                    LOG_INF("Switched to %dM PHY", desired_phy);
                }
            }

However, the error shows:

 [00:00:44.038,989] <wrn> bt_hci_core: opcode 0x2032 status 0x3a 
00> [00:00:44.039,003] <wrn> central_uart: PHY update failed (-5)
00> [00:00:44.039,009] <inf> central_uart: RXRX  = -18

Could you give me some advice?

Parents
  • Hi,

    0x3A is "Controller Busy", which indicates the BLE Controller is busy. How often are you attempting to change PHY? I suggest that you wait at least for a few seconds. I also suggest that you let the connection stabilize before you start to gather throughput statistics.

    You could also consider to not switch back and forth on the same value, but instead add some hysteresis to the system. (That is, for instance change to 1M if the rate drops below 700 and change to 2M if the rate goes above 900.)

    In any case, selecting PHY this way might or might not be a good idea. I think a better approach would be to use RSSI as an indicator of the link quality, and select PHY based on that. You could potentially also take packet loss rate into account. Regardless of method, make sure not to change PHY too often, and perform the measurements on a stable link (to not include in measurements the downtime for changing PHY or other parameters.)

    Regards,
    Terje

Reply
  • Hi,

    0x3A is "Controller Busy", which indicates the BLE Controller is busy. How often are you attempting to change PHY? I suggest that you wait at least for a few seconds. I also suggest that you let the connection stabilize before you start to gather throughput statistics.

    You could also consider to not switch back and forth on the same value, but instead add some hysteresis to the system. (That is, for instance change to 1M if the rate drops below 700 and change to 2M if the rate goes above 900.)

    In any case, selecting PHY this way might or might not be a good idea. I think a better approach would be to use RSSI as an indicator of the link quality, and select PHY based on that. You could potentially also take packet loss rate into account. Regardless of method, make sure not to change PHY too often, and perform the measurements on a stable link (to not include in measurements the downtime for changing PHY or other parameters.)

    Regards,
    Terje

Children
No Data
Related