PhilipsHue / flutter_reactive_ble

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

Request MTU and then `subscribeToCharacteristic` listener can't receive the notifications #774

Closed wcoder closed 5 months ago

wcoder commented 1 year ago

Describe the bug

The subscribeToCharacteristic listener can't receive the notifications after MTU was requested.

To Reproduce Steps to reproduce the behavior:

  1. Connect to one device using connectTo() / connectToAdvertisingDevice()
  2. Request MTU (512 - the device supports 498) -> requestMtu returns 498 or Request MTU (498 - the device supports 498) -> requestMtu returns 498
  3. Subscribe to a non-protected characteristic

Actual behavior

I/flutter ( 1897): REACTIVE_BLE: Start subscribing to notifications for QualifiedCharacteristic(characteristicId: XXX, serviceId: XXX, deviceId: XXX)
D/BluetoothGatt( 1897): setCharacteristicNotification() - uuid: XXX enable: true

and nothing

Expected behavior The subscribeToCharacteristic listener should receive the notification immediately after subscription.

Workaround

The solution that can help resolve this bug on example app project: #773

Smartphone / tablet

Peripheral device

chplalex commented 1 year ago

@wcoder I faced a similar issue but with another sign: the subscribeToCharacteristic listener received nothing without Request MTU (when the default MTU size is used). But, when I set the MTU to 247 (I requested 250), the listener began to receive values.

The issue occurs on Android. On iOS all works great for me.

I think the specific subscribeToCharacteristic request requires the relevant MTU size. When the actual MTU size is not relevant to the specific request, the listener receives nothing.

Try to play with MTU size.

Gufdoor commented 8 months ago

I faced the same issue and fortunately I found this topic. Tried requesting MTU and worked!

Taym95 commented 5 months ago

Make sure to request MTU then use subscribeToCharacteristic