From 28f386bdd63bc21ad469939d0f3f8e835ce1e841 Mon Sep 17 00:00:00 2001 From: Rohit Sangwan Date: Sun, 19 Jun 2022 17:40:44 +0530 Subject: [PATCH] Add Android WriteError --- .../kotlin/com/example/quick_blue/QuickBluePlugin.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/quick_blue/android/src/main/kotlin/com/example/quick_blue/QuickBluePlugin.kt b/packages/quick_blue/android/src/main/kotlin/com/example/quick_blue/QuickBluePlugin.kt index db2f868..36b5d8d 100644 --- a/packages/quick_blue/android/src/main/kotlin/com/example/quick_blue/QuickBluePlugin.kt +++ b/packages/quick_blue/android/src/main/kotlin/com/example/quick_blue/QuickBluePlugin.kt @@ -209,10 +209,12 @@ class QuickBluePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHand "ConnectionState" to "connected" )) } else { + // TODO Parse status code and send correct error messages cleanConnection(gatt) sendMessage(messageConnector, mapOf( "deviceId" to gatt.device.address, - "ConnectionState" to "disconnected" + "ConnectionState" to "disconnected", + "error" to "Disconnection Reason : Status $status" )) } } @@ -260,6 +262,13 @@ class QuickBluePlugin: FlutterPlugin, MethodCallHandler, EventChannel.StreamHand override fun onCharacteristicWrite(gatt: BluetoothGatt?, characteristic: BluetoothGattCharacteristic, status: Int) { Log.v(TAG, "onCharacteristicWrite ${characteristic.uuid}, ${characteristic.value.contentToString()} $status") + val deviceID = gatt?.device?.address ?: "" + // TODO Parse status code and send correct error messages + sendMessage(messageConnector, mapOf( + "deviceId" to deviceID, + "characteristic" to characteristic.uuid.toString(), + "error" to "Write Command Status : $status" + )) } override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) {