Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: reset connected if DISCONNECTED is received between connect and …
…initialize for autoconnected
  • Loading branch information
kkkbird committed Apr 16, 2024
commit a393efe3ba271b34efbcb8d2238518b5404cec8a
Original file line number Diff line number Diff line change
Expand Up @@ -2217,7 +2217,15 @@ public void onConnectionStateChange(@NonNull final BluetoothGatt gatt,

if (cr != null && cr.shouldAutoConnect() && initialConnection
&& gatt.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {
log(Log.DEBUG, () -> "autoConnect = false called failed; retrying with autoConnect = true");
log(Log.DEBUG, () -> "autoConnect = false called failed; retrying with autoConnect = true" + (connected ? "; reset connected to false" : ""));

// fix:https://github.com/NordicSemiconductor/Android-BLE-Library/issues/497
// if DISCONNECTED is received between connect and initialize, need to reset connected to make internalConnect work
if (connected) {
connected = false;
connectionState = BluetoothGatt.STATE_DISCONNECTED;
}

post(() -> internalConnect(gatt.getDevice(), cr));
return;
}
Expand Down