When there are cached services, skip service discovery
This commit is contained in:
parent
ce47f62c5b
commit
8154a887cb
|
@ -330,8 +330,14 @@ public final class BtLEQueue {
|
||||||
LOG.info("Connected to GATT server.");
|
LOG.info("Connected to GATT server.");
|
||||||
setDeviceConnectionState(State.CONNECTED);
|
setDeviceConnectionState(State.CONNECTED);
|
||||||
// Attempts to discover services after successful connection.
|
// Attempts to discover services after successful connection.
|
||||||
|
List<BluetoothGattService> cachedServices = gatt.getServices();
|
||||||
|
if (cachedServices != null && cachedServices.size() > 0) {
|
||||||
|
LOG.info("Using cached services, skipping discovery");
|
||||||
|
onServicesDiscovered(gatt, BluetoothGatt.GATT_SUCCESS);
|
||||||
|
} else {
|
||||||
LOG.info("Attempting to start service discovery:" +
|
LOG.info("Attempting to start service discovery:" +
|
||||||
gatt.discoverServices());
|
gatt.discoverServices());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BluetoothProfile.STATE_DISCONNECTED:
|
case BluetoothProfile.STATE_DISCONNECTED:
|
||||||
LOG.info("Disconnected from GATT server.");
|
LOG.info("Disconnected from GATT server.");
|
||||||
|
|
Loading…
Reference in New Issue