flutter_reactive_ble
flutter_reactive_ble copied to clipboard
Request MTU and then `subscribeToCharacteristic` listener can't receive the notifications
Describe the bug
The subscribeToCharacteristic
listener can't receive the notifications after MTU was requested.
To Reproduce Steps to reproduce the behavior:
- Connect to one device using
connectTo()
/connectToAdvertisingDevice()
- Request MTU (512 - the device supports 498) ->
requestMtu
returns 498 or Request MTU (498 - the device supports 498) ->requestMtu
returns 498 - 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 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.
I faced the same issue and fortunately I found this topic. Tried requesting MTU and worked!
Make sure to request MTU then use subscribeToCharacteristic