mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Fix Bluetooth reconnection logic (#2948)
This commit is contained in:
parent
76ddd29114
commit
48679f4436
1 changed files with 5 additions and 1 deletions
|
|
@ -557,8 +557,12 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
|
||||
fun asyncConnect(autoConnect: Boolean = false, cb: (Result<Unit>) -> Unit, lostConnectCb: () -> Unit) {
|
||||
logAssert(workQueue.isEmpty())
|
||||
|
||||
// If there's already connection work in progress, clear it before starting new connection
|
||||
// This can happen during reconnection where previous connection work wasn't properly cleared
|
||||
if (currentWork != null) {
|
||||
throw AssertionError("currentWork was not null: $currentWork")
|
||||
warn("Found existing work during asyncConnect: $currentWork - clearing it")
|
||||
synchronized(workQueue) { stopCurrentWork() }
|
||||
}
|
||||
|
||||
lostConnectCallback = lostConnectCb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue