fix: 修复 getMaximumWriteLength 断开时未回调结果的问题 (#15)

This commit is contained in:
Mr剑侠客
2023-09-11 14:13:43 +08:00
committed by GitHub
parent 78bcb88563
commit 073c2b9a2e
7 changed files with 27 additions and 15 deletions

View File

@ -450,6 +450,10 @@ class MyCentralController(private val context: Context, binaryMessenger: BinaryM
gatt.close()
cachedGATTs.remove(deviceKey)
val error = IllegalStateException("GATT is disconnected with status: $status")
val getMaximumWriteLengthCallback = getMaximumWriteLengthCallbacks.remove(deviceKey)
if (getMaximumWriteLengthCallback != null) {
getMaximumWriteLengthCallback(Result.failure(error))
}
val discoverGattCallback = discoverGattCallbacks.remove(deviceKey)
if (discoverGattCallback != null) {
discoverGattCallback(Result.failure(error))