flutter_reactive_ble icon indicating copy to clipboard operation
flutter_reactive_ble copied to clipboard

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

Open wcoder opened this issue 1 year ago • 2 comments

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.

  • [x] I tried doing the same with nRF Connect (on Android and iOS) and it exhibits the expected behavior as described above
  • [x] I tried doing the same with different Android util apps and it exhibits the expected behavior as described above

Workaround

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

Smartphone / tablet

  • Device: Samsung, Xiaomi
  • OS: Android 10+
  • Package version: 5.0.3

Peripheral device

  • Vendor, model: Custom, Zefyr BLE
  • Does it run a custom firmware: yes

wcoder avatar Jul 17 '23 13:07 wcoder

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

chplALEX avatar Aug 03 '23 07:08 chplALEX

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

Gufdoor avatar Jan 03 '24 19:01 Gufdoor

Make sure to request MTU then use subscribeToCharacteristic

Taym95 avatar Apr 08 '24 11:04 Taym95