From 1f0092bbe19429275689e01436da23e3cdb7d206 Mon Sep 17 00:00:00 2001 From: Tavis Date: Wed, 18 Dec 2024 01:14:16 -1000 Subject: [PATCH] fix: handle `GATT_CONNECTION_TIMEOUT` status in Bluetooth connection state change (#1463) * Trap code 147 on BT disconnect If we trap code 147 on BT disconnect and then call lostConnection(), the app will attempt reconnect every 30 seconds and autoreconnect works even after prolonged disconnect. --- app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt index 4dbc4f771..988c49877 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt @@ -209,6 +209,9 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD closeGatt() // Close the old non-auto connection lowLevelConnect(true) } + } else if (status == 147) { + info("got 147, calling lostConnection()") + lostConnection("code 147") } if (status == 257) { // mystery error code when phone is hung