Skip to content

Commit

Permalink
Reading PHY if no callback for setting preferred one
Browse files Browse the repository at this point in the history
  • Loading branch information
philips77 committed Sep 29, 2022
1 parent f73171c commit 46d1781
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ble/src/main/java/no/nordicsemi/android/ble/BleManagerHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3501,8 +3501,24 @@ private synchronized void nextRequest(final boolean force) {
//noinspection ConstantConditions
final PhyRequest pr = (PhyRequest) request;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
result = internalSetPreferredPhy(pr.getPreferredTxPhy(),
pr.getPreferredRxPhy(), pr.getPreferredPhyOptions());
result = internalSetPreferredPhy(
pr.getPreferredTxPhy(),
pr.getPreferredRxPhy(),
pr.getPreferredPhyOptions()
);
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.TIRAMISU) {
// There seems to be a bug on Android 13, where there is no callback
// for setPreferredPhy(...). onPhyUpdate(...) should be called, but it is not.
// See: https://github.com/NordicSemiconductor/Android-BLE-Library/issues/414
// However, the operation seems to complete successfully.
// As a workaround, let's read the PHYs and notify the user.
handler.postDelayed(() -> {
if (!pr.finished) {
log(Log.WARN, () -> "Callback not received in 1000 ms");
internalReadPhy();
}
}, 1000);
}
} else {
result = connected;
if (result) {
Expand Down

0 comments on commit 46d1781

Please sign in to comment.