fix autobug: some phones call gatt connected but with an error status code

This commit is contained in:
geeksville
2020-04-20 10:37:46 -07:00
parent 428ea596b0
commit 2a52b707ee
3 changed files with 7 additions and 5 deletions

View File

@@ -354,7 +354,7 @@ class RadioInterfaceService : Service(), Logging {
private fun onConnect(connRes: Result<Unit>) {
// This callback is invoked after we are connected
connRes.getOrThrow() // FIXME, instead just try to reconnect?
connRes.getOrThrow()
info("Connected to radio!")
if (!hasForcedRefresh) {

View File

@@ -154,9 +154,11 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
BluetoothProfile.STATE_CONNECTED -> {
state =
newState // we only care about connected/disconnected - not the transitional states
//logAssert(workQueue.isNotEmpty())
//val work = workQueue.removeAt(0)
completeWork(status, Unit)
if (status != BluetoothGatt.GATT_SUCCESS) {
errormsg("Connect attempt failed $status, not calling connect completion handler...")
} else
completeWork(status, Unit)
}
BluetoothProfile.STATE_DISCONNECTED -> {
// cancel any queued ops if we were already connected