From 4172b221f03c2094df67dee30387b401cd0ff2d7 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 30 Jun 2020 12:35:58 -0700 Subject: [PATCH] autobug: failure to start should be treated like any other BLE exception --- .../java/com/geeksville/mesh/service/SafeBluetooth.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 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 500207a8d..ec3bf6dee 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt @@ -121,6 +121,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD // Our own custom BLE status codes private val STATUS_RELIABLE_WRITE_FAILED = 4403 private val STATUS_TIMEOUT = 4404 + private val STATUS_NOSTART = 4405 private val gattCallback = object : BluetoothGattCallback() { @@ -310,7 +311,14 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD isSettingMtu = false // Most work is not doing MTU stuff, the work that is will re set this flag - logAssert(newWork.startWork()) + val started = newWork.startWork() + if (!started) { + errormsg("Failed to start work, returned error status") + completeWork( + STATUS_NOSTART, + Unit + ) // abandon the current attempt and try for another + } } }