dotintent / FlutterBleLib

Bluetooth Low Energy library for Flutter with support for simulating peripherals
Apache License 2.0
535 stars 197 forks source link

can't read from readable Characteristic #514

Open Matrix-Zhang opened 4 years ago

Matrix-Zhang commented 4 years ago
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

mikolak commented 4 years ago

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

Matrix-Zhang commented 4 years ago

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)
mikolak commented 4 years ago

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...

Matrix-Zhang commented 4 years ago

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....

mikolak commented 4 years ago

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

Matrix-Zhang commented 4 years ago

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 commented 4 years ago

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
mikolak commented 3 years ago

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

Matrix-Zhang commented 3 years ago

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

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