I am starting to look at using 2Mbps Phy (and eventually coded PHY). I'd like to add the functionality where my device will automatically switch PHYs based on some metric in order to give the best performance e.g. 2Mbps when close, 1Mbps when too far away for 2Mbps, and finally coded PHY for long range.
Is RSSI the best indicator to use?
Should I just start RSSI measurement using sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count) then on the BLE_GAP_EVT_RSSI_CHANGED event, change PHY accordingly?
Does anyone have any info on when the best time to switch is i.e., at which RSSI values should i change to the next PHY option
Is there a way to check which modes the device I'm connected to supports, without trying sd_ble_gap_phy_update and checking the result in BLE_GAP_EVT_PHY_UPDATE ?
I think the RSSI can be a good indicator for determining what PHY to use. Sampling of RSSI is started by calling sd_ble_gap_rssi_start() as you said, and BLE_GAP_EVT_RSSI_CHANGED will be reported once the RSSI crosses the chosen threshold.
I'm not sure what the best time to switch phy would be, maybe 5-10 dB below max. receiver sensitivity, or more if the device can get quickly out of range.
It's not possible to check which modes the peer device support without sending a phy update request.
Thanks Vidar. I've implemented this and keep track of which PHYs the device supports using ble_conn_state flags. It works pretty well. If it's a bonded peer, I also store these using pm_peer_data_app_data_store
Looking at the receiver sensitivities seems to show that I can use 2Mbps PHY at almost the same range of dBm as 1Mbps
Good idea to use the pm to store PHY support for peer devices. With regards to receiver sensitivity, 6 dB difference will actually have a significant impact on range even though it doesn't sound like much (40 % increase in theory, likely less in practice).