PhilipsHue / flutter_reactive_ble

Flutter library that handles BLE operations for multiple devices.
https://developers.meethue.com/
Other
661 stars 321 forks source link

Intermittent Read Failure Leading to Automatic Disconnection with flutter_reactive_ble #846

Open loziobrown opened 6 months ago

loziobrown commented 6 months ago

Environment:

Device: Samsung Tablet running Android 13 Peripheral: NINAB31 module Flutter version: 3.16.9 flutter_reactive_ble version: 5.3.1

Issue Description:

I am encountering an intermittent issue where reading from a characteristic using the flutter_reactive_ble library occasionally results in an error, followed by an automatic disconnection from the BLE device. This issue does not occur consistently but seems to arise sporadically during characteristic reads. Error Message: Error reading characteristic: 9006: Exception: GenericFailure<CharacteristicValueUpdateError>(code: CharacteristicValueUpdateError.unknown, message: "GATT exception from MAC address 6C:1D:EB:32:36:66, with type BleGattOperation{description='CHARACTERISTIC_READ'}")

After this error is logged, the BLE device disconnects automatically.

Additional Context:

The issue seems to occur randomly during characteristic reads. When the error occurs, if I attempt to read the same characteristic using a different BLE scanner tool, the read operation succeeds without any issues. This leads me to believe that the issue might be related to how flutter_reactive_ble handles read operations or manages connections under certain conditions.

Potential Solution (maybe): I am wondering if implementing a read timeout or providing a retry mechanism within the flutter_reactive_ble library might mitigate this issue. Such a feature could allow the application to attempt the read operation again before considering it a failure and disconnecting.

xvrh commented 3 months ago

@loziobrown wondering if you've found a solution/workaround for this? We also have some intermittent disconnection after characteristic (write in our case). We have no clue if the problem is in the firmware or the smartphone. But it only does that on Android devices.