Only attempt to reconnect when we were previously initialized
This commit is contained in:
parent
91d1cea51f
commit
8549031c6f
|
@ -198,6 +198,7 @@ public final class BtLEQueue {
|
||||||
if (mWaitForActionResultLatch != null) {
|
if (mWaitForActionResultLatch != null) {
|
||||||
mWaitForActionResultLatch.countDown();
|
mWaitForActionResultLatch.countDown();
|
||||||
}
|
}
|
||||||
|
boolean wasInitialized = mGbDevice.isInitialized();
|
||||||
setDeviceConnectionState(State.NOT_CONNECTED);
|
setDeviceConnectionState(State.NOT_CONNECTED);
|
||||||
|
|
||||||
// either we've been disconnected because the device is out of range
|
// either we've been disconnected because the device is out of range
|
||||||
|
@ -207,7 +208,7 @@ public final class BtLEQueue {
|
||||||
// reconnecting automatically, so we try to fix this by re-creating mBluetoothGatt.
|
// reconnecting automatically, so we try to fix this by re-creating mBluetoothGatt.
|
||||||
// Not sure if this actually works without re-initializing the device...
|
// Not sure if this actually works without re-initializing the device...
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
if (!maybeReconnect()) {
|
if (!wasInitialized || !maybeReconnect()) {
|
||||||
disconnect(); // ensure that we start over cleanly next time
|
disconnect(); // ensure that we start over cleanly next time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue