ignore BLE errors while closing

1.2-legacy
Kevin Hester 2021-03-23 13:17:36 +08:00
rodzic 2327c5e693
commit cea7755aa4
3 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -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")
open class BLECharacteristicNotFoundException(uuid: UUID) : BLEException("Can't get characteristic $uuid")
/// Our interface is being shut down
open class BLEConnectionClosing() : BLEException("Connection closing ")

Wyświetl plik

@ -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")
}

Wyświetl plik

@ -773,7 +773,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
closeGatt()
failAllWork(BLEException("Connection closing"))
failAllWork(BLEConnectionClosing())
}
/**