Skip to content

Commit

Permalink
fix: Fixed IllegalStateException: Already resumed on cancelConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiky committed May 13, 2022
1 parent bf12a2f commit af74bdd
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,12 @@ class BluetoothCentralManager(private val context: Context) {
suspend fun cancelConnection(peripheral: BluetoothPeripheral): Unit =
suspendCoroutine {
cancelConnection(peripheral, object : BluetoothCentralManagerCallback() {
var resumed = false
override fun onDisconnectedPeripheral(peripheral: BluetoothPeripheral, status: HciStatus) {
it.resume(Unit)
if (!resumed) {
it.resume(Unit)
resumed = true
}
}
})
}
Expand Down

0 comments on commit af74bdd

Please sign in to comment.