diff --git a/app/src/main/java/com/geeksville/mesh/service/BLEException.kt b/app/src/main/java/com/geeksville/mesh/service/BLEException.kt index 4ee38cd1b..7aa2724bf 100644 --- a/app/src/main/java/com/geeksville/mesh/service/BLEException.kt +++ b/app/src/main/java/com/geeksville/mesh/service/BLEException.kt @@ -5,4 +5,7 @@ import java.util.* open class BLEException(msg: String) : IOException(msg) -open class BLECharacteristicNotFoundException(uuid: UUID) : BLEException("Can't get characteristic $uuid") \ No newline at end of file +open class BLECharacteristicNotFoundException(uuid: UUID) : BLEException("Can't get characteristic $uuid") + +/// Our interface is being shut down +open class BLEConnectionClosing() : BLEException("Connection closing ") \ No newline at end of file diff --git a/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt b/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt index 59489907c..1fbfdcad2 100644 --- a/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt +++ b/app/src/main/java/com/geeksville/mesh/service/BluetoothInterface.kt @@ -469,7 +469,12 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String safe = null // We do this first, because if we throw we still want to mark that we no longer have a valid connection - s?.close() + try { + s?.close() + } + catch(_: BLEConnectionClosing) { + warn("Ignoring BLE errors while closing") + } } else { debug("Radio was not connected, skipping disable") } 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 283ed00fc..c77830656 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt @@ -773,7 +773,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD closeGatt() - failAllWork(BLEException("Connection closing")) + failAllWork(BLEConnectionClosing()) } /**