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?

Related