From 27b1e4d4b13a9b25b5020fa586e354fdf30ca4bf Mon Sep 17 00:00:00 2001 From: Tavis Date: Fri, 13 Dec 2024 12:10:02 -1000 Subject: [PATCH 1/4] Fix the "must click None" to manually reconnect problem. --- .../geeksville/mesh/repository/radio/RadioInterfaceService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt index 2b629cd69..bc60fc684 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt @@ -259,7 +259,7 @@ class RadioInterfaceService @Inject constructor( * @return true if the device changed, false if no change */ private fun setBondedDeviceAddress(address: String?): Boolean { - return if (getBondedDeviceAddress() == address && isStarted) { + return if (getBondedDeviceAddress() == address && isStarted && isConnected) { warn("Ignoring setBondedDevice ${address.anonymize}, because we are already using that device") false } else { From 2f73444f7bdae8ed36fc4d3f834d5d24fe1400b0 Mon Sep 17 00:00:00 2001 From: Tavis Date: Fri, 13 Dec 2024 12:11:12 -1000 Subject: [PATCH 2/4] 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..33fba5672 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 From e886fcd056b637036892a669ce4cdb88634daa6b Mon Sep 17 00:00:00 2001 From: Tavis Date: Sat, 14 Dec 2024 00:15:33 -1000 Subject: [PATCH 3/4] delete errant space on line 213 --- app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 33fba5672..988c49877 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt @@ -210,7 +210,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD lowLevelConnect(true) } } else if (status == 147) { - info( "got 147, calling lostConnection()") + info("got 147, calling lostConnection()") lostConnection("code 147") } From caae37ed4f5970f0454c83e5d371a81d4e2ca4fe Mon Sep 17 00:00:00 2001 From: Tavis Date: Sun, 15 Dec 2024 00:56:00 -1000 Subject: [PATCH 4/4] Revert "Fix the "must click None" to manually reconnect problem." This reverts commit 27b1e4d4b13a9b25b5020fa586e354fdf30ca4bf. --- .../geeksville/mesh/repository/radio/RadioInterfaceService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt index 14c9f7281..b6963a233 100644 --- a/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt +++ b/app/src/main/java/com/geeksville/mesh/repository/radio/RadioInterfaceService.kt @@ -276,7 +276,7 @@ class RadioInterfaceService @Inject constructor( * @return true if the device changed, false if no change */ private fun setBondedDeviceAddress(address: String?): Boolean { - return if (getBondedDeviceAddress() == address && isStarted && isConnected) { + return if (getBondedDeviceAddress() == address && isStarted) { warn("Ignoring setBondedDevice ${address.anonymize}, because we are already using that device") false } else {