FlutterBleLib icon indicating copy to clipboard operation
FlutterBleLib copied to clipboard

can't read from readable Characteristic

Open Matrix-Zhang opened this issue 3 years ago • 9 comments

D/com.polidea.flutter_ble_lib.FlutterBleLibPlugin( 7591): on native side observed method: readCharacteristicForIdentifier
E/flutter ( 7591): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: BleError (Error code: 2, ATT error code: null, iOS error code: null, Android error code: null, reason: null, internal message: null, device ID: null, service UUID: null, characteristic UUID: null, descriptor UUID: null)
E/flutter ( 7591): 

use the monitor is ok

Matrix-Zhang avatar Aug 25 '20 13:08 Matrix-Zhang

Error code 2 means operation cancelled. I think you might've passed the same transaction ID to two operations.

mikolak avatar Aug 25 '20 16:08 mikolak

Error code 2 means operation cancelled. I think you might've passed the same transaction ID to two operations.

Okay, i think the transaction id is session id....

after i remove the transaction id, new error comes

E/flutter (24967): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: BleError (Error code: 3, ATT error code: null, iOS error code: null, Android error code: null, reason: GATT exception from MAC address 5B:14:86:24:98:64, with type BleGattOperation{description='CHARACTERISTIC_READ'}, internal message: null, device ID: null, service UUID: null, characteristic UUID: null, descriptor UUID: null)

Matrix-Zhang avatar Aug 26 '20 02:08 Matrix-Zhang

3 is operation timeout. https://github.com/Polidea/FlutterBleLib/blob/develop/lib/error/ble_error.dart

This library is based on our React Native BLE library and some things are directly translated from there. You can check out what the errors mean here: https://polidea.github.io/react-native-ble-plx/#bleerrorcode

I need to add docs to those error codes here...

mikolak avatar Aug 26 '20 15:08 mikolak

3 is operation timeout. https://github.com/Polidea/FlutterBleLib/blob/develop/lib/error/ble_error.dart

This library is based on our React Native BLE library and some things are directly translated from there. You can check out what the errors mean here: https://polidea.github.io/react-native-ble-plx/#bleerrorcode

I need to add docs to those error codes here...

why timeout? if i remove the Characteristic's read method, just listen on Characteristic's monitor, the data will received....

Matrix-Zhang avatar Aug 26 '20 15:08 Matrix-Zhang

I don't why, I haven't seen your code. 🙂 If you're not monitoring, does the read succeed?

mikolak avatar Aug 26 '20 16:08 mikolak

I don't why, I haven't seen your code. 🙂 If you're not monitoring, does the read succeed?

if i not monitoring, the read timeout,

the code just like:

write("1234") ; //send to peripheral success, peripheral will received the data
read(); // read from peripheral timeout, if change to monitor, data coming

Matrix-Zhang avatar Aug 27 '20 00:08 Matrix-Zhang

if android read from ios, the error code is 402

session error: BleError (Error code: 402, ATT error code: null, iOS error code: null, Android error code: 241, reason: GATT exception from MAC address 7B:B1:06:39:0D:F1, status 241 (UNKNOWN), type BleGattOperation{description='CHARACTERISTIC_READ'}. (Look up status 0xf1 here https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1

Matrix-Zhang avatar Aug 31 '20 03:08 Matrix-Zhang

Can you check the permissions on your characteristic? (isReadable, isWritable, etc.)

mikolak avatar Sep 16 '20 15:09 mikolak

Can you check the permissions on your characteristic? (isReadable, isWritable, etc.)

yes, i have checked it already, the characteristic is readable

Matrix-Zhang avatar Sep 21 '20 01:09 Matrix-Zhang