Skip to content

Commit

Permalink
Trigger service discovery if interrupted in onConnectionUpdated
Browse files Browse the repository at this point in the history
It appears that when a service discovery is in progress and
`onConnectionUpdated` is called, the service discovery callback
`onServicesDiscovered` is never invoked. By checking to see
`serviceDiscoverRequested` is set, we can restart the service discovery
and get a result back.

This may potentially fix NordicSemiconductor#536, but I was seeing this behaviour
consistently when connecting to another BLE device
  • Loading branch information
cwgthornton committed Feb 22, 2025
1 parent 9504515 commit 2ffc804
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,11 @@ public void onConnectionUpdated(@NonNull final BluetoothGatt gatt,
cpr.notifyConnectionPriorityChanged(gatt.getDevice(), interval, latency, timeout);
cpr.notifySuccess(gatt.getDevice());
}
if (serviceDiscoveryRequested) {
log(Log.VERBOSE, () -> "Discovering services...");
log(Log.DEBUG, () -> "gatt.discoverServices()");
bluetoothGatt.discoverServices();
}
} else if (status == 0x3b) { // HCI_ERR_UNACCEPT_CONN_INTERVAL
Log.e(TAG, "onConnectionUpdated received status: Unacceptable connection interval, " +
"interval: " + interval + ", latency: " + latency + ", timeout: " + timeout);
Expand Down

0 comments on commit 2ffc804

Please sign in to comment.