flutter_reactive_ble icon indicating copy to clipboard operation
flutter_reactive_ble copied to clipboard

Android low level library crash when the BLE device disconnects unexpectedly

Open cmillauriaux opened this issue 2 months ago • 0 comments

Describe the bug When I connect my Flutter application to a BLE object on battery, when the object runs out of battery and shuts down unexpectedly, the application crashes with a Java error stack

To Reproduce Steps to reproduce the behavior:

  1. Connect to one device using connectTo()
  2. subscribe to a protected characteristic
  3. BLE peripheral shutdown because it runs out of battery
  4. Observe a failure with exception
io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='XX:XX:XX:XX:XX:XX' with status 133 (GATT_ERROR)
                                                                                                    	at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
                                                                                                    	at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:83)
                                                                                                    	at io.reactivex.internal.operators.observable.ObservableRetryPredicate$RepeatObserver.onError(ObservableRetryPredicate.java:90)
                                                                                                    	at io.reactivex.observers.SerializedObserver.onError(SerializedObserver.java:153)
                                                                                                    	at io.reactivex.internal.operators.observable.ObservableDelay$DelayObserver$OnError.run(ObservableDelay.java:128)
                                                                                                    	at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
                                                                                                    	at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
                                                                                                    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                                                                                                    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                                                                                                    	at java.lang.Thread.run(Thread.java:919)
                                                                                                    Caused by: com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='XX:XX:XX:XX:XX:XX' with status 133 (GATT_ERROR)
                                                                                                    	at com.polidea.rxandroidble2.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:81)
                                                                                                    	at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:272)
                                                                                                    	at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:780)
                                                                                                    	at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:41)
                                                                                                    	at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:267)
                                                                                                    	at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:192)
                                                                                                    	at android.os.Binder.execTransactInternal(Binder.java:1021)
                                                                                                    	at android.os.Binder.execTransact(Binder.java:994)

Expected behavior A catchable error to close the connexion on Flutter side

Smartphone / tablet

  • Device: Famoco
  • OS: Android 10
  • Package version: 5.2.0

Peripheral device

  • Vendor, model: Custom STMicroElectronics BLE device
  • Does it run a custom firmware / software: yes

cmillauriaux avatar Apr 26 '24 11:04 cmillauriaux