Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class BLEComm @Inject internal constructor(
} else {
aapsLogger.debug(LTag.PUMPBTCOMM, "Not connected, closing gatt")
close()
isConnected = false
mCallback?.onBLEDisconnected()
}
}
Expand All @@ -198,6 +197,8 @@ class BLEComm @Inject internal constructor(
mBluetoothGatt?.close()
SystemClock.sleep(100)
mBluetoothGatt = null
isConnected = false
isConnecting = false
}

/** Scan callback */
Expand Down Expand Up @@ -387,11 +388,12 @@ class BLEComm @Inject internal constructor(
// Wait a bit before retrying
SystemClock.sleep(2000)
}
close()
isConnected = false
isConnecting = false
mCallback?.onBLEDisconnected()
aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected
// CLosing asynchronously to avoid deadlocks or silent failures in the Android BLE callback thread during disconnect.
handler.post {
close()
mCallback?.onBLEDisconnected()
aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected
}
}
}

Expand Down