diff --git a/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt b/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt index 2c3f124..ed11a32 100644 --- a/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt +++ b/blessed/src/main/java/com/welie/blessed/BluetoothCentralManager.kt @@ -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 + } } }) }