Fix Android cleanup on gatt disconnect (#109)
This commit is contained in:
@@ -178,9 +178,9 @@ fun <T> SparseArray<T>.toList(): List<Pair<Int, T>> {
|
||||
fun BluetoothGatt.getCharacteristic(
|
||||
service: String,
|
||||
characteristic: String,
|
||||
): BluetoothGattCharacteristic? =
|
||||
getService(UUID.fromString(service)).getCharacteristic(UUID.fromString(characteristic))
|
||||
|
||||
): BluetoothGattCharacteristic? {
|
||||
return getService(UUID.fromString(service))?.getCharacteristic(UUID.fromString(characteristic))
|
||||
}
|
||||
|
||||
fun subscriptionFailedError(error: String? = null): Result<Unit> {
|
||||
return Result.failure(
|
||||
|
||||
@@ -716,7 +716,6 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(),
|
||||
private fun cleanConnection(gatt: BluetoothGatt) {
|
||||
knownGatts.remove(gatt)
|
||||
gatt.disconnect()
|
||||
gatt.close()
|
||||
|
||||
readResultFutureList.removeAll {
|
||||
if (it.deviceId == gatt.device.address) {
|
||||
@@ -885,6 +884,8 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(),
|
||||
gatt.device.address, false, status.parseHciErrorCode()
|
||||
) {}
|
||||
}
|
||||
Log.d(TAG, "Closing gatt for ${gatt.device.name}")
|
||||
gatt.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user