yanshouwang / bluetooth_low_energy

A Flutter plugin for controlling the bluetooth low energy.
https://pub.dev/packages/bluetooth_low_energy
MIT License
50 stars 16 forks source link

android device: requestMtu issue #22

Closed spiderman16888 closed 1 year ago

spiderman16888 commented 1 year ago

D/BluetoothGatt(24178): configureMTU() - device: D029BA_C mtu: 517 D/BluetoothGatt(24178): onConnectionUpdated() - Device=D029BA_C interval=36 latency=0 timeout=500 status=0 D/BluetoothGatt(24178): onConfigureMTU() - Device=D029BA_C mtu=247 status=4 I/flutter (24178): error: PlatformException(IllegalStateException, java.lang.IllegalStateException: Request MTU failed with status: 4, Cause: null, Stacktrace: java.lang.IllegalStateException: Request MTU failed with status: 4 I/flutter (24178): at dev.yanshouwang.bluetooth_low_energy_android.MyCentralManager.onMtuChanged(MyCentralManager.kt:522) I/flutter (24178): at dev.yanshouwang.bluetooth_low_energy_android.MyBluetoothGattCallback.onMtuChanged$lambda$1(MyBluetoothGattCallback.kt:21) I/flutter (24178): at dev.yanshouwang.bluetooth_low_energy_android.MyBluetoothGattCallback.$r8$lambda$YuSPH4xgjMukXLzXKi-mkORqrJ4(Unknown Source:0) I/flutter (24178): at dev.yanshouwang.bluetooth_low_energy_android.MyBluetoothGattCallback$$ExternalSyntheticLambda5.run(Unknown Source:8) I/flutter (24178): at android.os.Handler.handleCallback(Handler.java:942)

yanshouwang commented 1 year ago

This means the MTU request is failed, I called requestMtu after GATT discovered in the newest version, and if the request is failed, the discoverGATT will throw this error, will fix this behavior in the next version. the status 4 seems releated with multiple MTU requests, look at this: status = 4 error when calling requestMtu for twice in Android APP I suggest to use version 3.0.1 if you can't resolve this error, this will be fixed as soon as possible.