scientifichackers / flutter-rx-ble

A Flutter BLE plugin, based on RxAndroidBle and RxBluetoothKit.
GNU Lesser General Public License v3.0
35 stars 18 forks source link

Exception when disconnecting from device #18

Closed 01xJoao closed 5 years ago

01xJoao commented 5 years ago

This only happens when the device already sent me some data.

When I disconnect I get the following exception on iOS:

  if (Platform.isIOS) {
    throw BleException(message, details);
  }

message:

"The operation couldn’t be completed. (RxBluetoothKit.BluetoothError error 4.)"

details:

0 plugin_scaffold 0x0000000104ae3e50 $s15plugin_scaffold14serializeErrorySo07FlutterD0CypF + 316 1 plugin_scaffold 0x0000000104ae5b74 $s15plugin_scaffold7trySendyyyypSgcACyKcSgtFyycfU + 544 2 plugin_scaffold 0x0000000104ae51d0 $sIeg_IeyB_TR + 52 3 plugin_scaffold 0x0000000104ae35d0 +[PluginScaffoldHelper tryCatch:onCatch:onElse:] + 108 4 plugin_scaffold 0x0000000104ae5874 $s15plugin_scaffold7trySendyyyypSgc_ACyKcSgtF + 792 5 plugin_scaffold 0x0000000104ae6194 $s15plugin_scaffold12trySendErroryyyypSgc_s0E0_ptF + 192 6 rx_ble 0x0000000104b191bc $s6rx_ble16ReadWriteMethodsC8onListen2id4args4sinkySi_ypSgyAHctKFys5ErrorpcfU0 + 120 7 RxSwift 0x0000000106b5f340 $s7RxSwift14ObservableTypePAAE9subscribe6onNext0F5Error0F9Completed0F8DisposedAA10Disposable_py7ElementQzcSg_ys0H0pcSgyycSgAOtFyAA5EventOyAKGcfU + 952 8 RxSwift 0x0000000106b5f688 $s7RxSwift14ObservableTypePAAE9subscribe6onNext0F5Error0F9Completed0F8DisposedAA10Disposable_py7ElementQzcSg_ys0H0_pcSgyycSgAOtFyAA5EventOyAKGcfU_TA + 88 9 RxSwift 0x0000000106a8f54c $s7RxSwift17AnonymousObserverC6onCoreyyAA5EventOyxGF + 160 10 RxSwift 0x0000000106b676f8 $s7RxSwift12ObserverBaseC2onyyAA5EventOyxGF + 380 11 RxSwift 0x0000000106b679fc $s7RxSwift12ObserverBaseCyxGAA0C4TypeA2aEP2onyyAA5EventOy7ElementQzGFTW + 28 12 RxSwift 0x0000000106bb97cc $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 288 13 RxSwift 0x0000000106af9b64 $s7RxSwift23AnonymousObservableSink33_95EBF5692819D58425EC2DD0512D115ALLC2onyyAA5EventOy7ElementQzGF + 512 14 RxSwift 0x0000000106af9fd8 $s7RxSwift23AnonymousObservableSink33_95EBF5692819D58425EC2DD0512D115ALLCyxGAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 20 15 RxSwift 0x0000000106a90e14 $sTA + 132 16 RxSwift 0x0000000106a902b8 $s7RxSwift11AnyObserverV2onyyAA5EventOyxGF + 156 17 RxBluetoothKit 0x000000010489bc88 $s7RxSwift14ObservableTypeP0A12BluetoothKitE6absorbyAA0C0Cy7ElementQzGAJ_AJtFZAA10Disposable_pAA11AnyObserverVyAIGcfUyAA5EventOyAIGcfU + 276 18 RxSwift 0x0000000106a902b8 $s7RxSwift11AnyObserverV2onyyAA5EventOyxGF + 156 19 RxSwift 0x0000000106a90334 $s7RxSwift11AnyObserverVyxGAA0D4TypeA2aEP2onyyAA5EventOy7ElementQzGFTW + 28 20 RxSwift 0x0000000106bb97cc $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 288 21 RxSwift 0x0000000106b07764 $s7RxSwift12DeferredSink33_9A640CB28D6420293D75F113534DFAC6LLC2onyyAA5EventOy7ElementQzGF + 260 22 RxSwift 0x0000000106b08364 $s7RxSwift12DeferredSink33_9A640CB28D6420293D75F113534DFAC6LLCyxq_GAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 20 23 RxSwift 0x0000000106bb97cc $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 288 24 RxSwift 0x0000000106b3de7c $s7RxSwift7MapSink33_5428EFA9A9B0C0340021B871D2E5AC01LLC2onyyAA5EventOyxGF + 1536 25 RxSwift 0x0000000106b3e930 $s7RxSwift7MapSink33_5428EFA9A9B0C0340021B871D2E5AC01LLCyxq_GAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 20 26 RxSwift 0x0000000106bb97cc $s7RxSwift4SinkC9forwardOnyyAA5EventOy7ElementQzGF + 288 27 RxSwift 0x0000000106b2a54c $s7RxSwift10FilterSink33_172A575932639FDD42969ED91F7BE949LLC2onyyAA5EventOy7ElementQzGF + 704 28 RxSwift 0x0000000106b2b22c $s7RxSwift10FilterSink33_172A575932639FDD42969ED91F7BE949LLCyxGAA12ObserverTypeA2aFP2onyyAA5EventOy7ElementQzGFTW + 20 29 RxSwift 0x0000000106a90e14 $sTA + 132 30 RxSwift 0x0000000106a98d80 $s7RxSwift5EventOyxGIegn_ADytIegnr_7ElementQydRszAA12ObserverTypeRdr__lTR + 20 31 RxSwift 0x0000000106a993b8 $s7RxSwift5EventOyxGytIegnr_ADIegn_lTR + 28 32 RxSwift 0x0000000106a9b430 $s7RxSwift8dispatchyyAA3BagVyyAA5EventOyxGcG_AGtlF + 1036 33 RxSwift 0x0000000106b79bb4 $s7RxSwift14PublishSubjectC2onyyAA5EventOyxGF + 176 34 RxSwift 0x0000000106b7b6a8 $s7RxSwift14PublishSubjectCyxGAA12ObserverTypeA2aEP2onyyAA5EventOy7ElementQzGFTW + 20 35 RxSwift 0x0000000106b67bec $s7RxSwift12ObserverTypePAAE6onNextyy7ElementQzF + 308 36 RxBluetoothKit 0x0000000104872700 $s14RxBluetoothKit31CBCentralManagerDelegateWrapperC07centralE0_23didDisconnectPeripheral5errorySo0dE0C_So12CBPeripheralCs5Error_pSgtF + 492 37 RxBluetoothKit 0x0000000104872ad0 $s14RxBluetoothKit31CBCentralManagerDelegateWrapperC07centralE0_23didDisconnectPeripheral5errorySo0dE0C_So12CBPeripheralCs5Error_pSgtFTo + 168 38 CoreBluetooth 0x00000001c65183f4 + 232 39 CoreBluetooth 0x00000001c65191f0 + 620 40 CoreBluetooth 0x00000001c6527438 + 60 41 libdispatch.dylib 0x00000001c043ca38 + 24 42 libdispatch.dylib 0x00000001c043d7d4 + 16 43 libdispatch.dylib 0x00000001c0418dec + 548 44 libdispatch.dylib 0x00000001c0419964 + 464 45 libdispatch.dylib 0x00000001c041d8d4 + 736 46 CoreFoundation 0x00000001c099032c + 12 47 CoreFoundation 0x00000001c098b264 + 1924 48 CoreFoundation 0x00000001c098a7c0 CFRunLoopRunSpecific + 436 49 GraphicsServices 0x00000001c2b8b79c GSEventRunModal + 104 50 UIKitCore 0x00000001ed48fc38 UIApplicationMain + 212 51 Runner 0x0000000104850f70 main + 124 52 libdyld.dylib 0x00000001c044e8e0 + 4

01xJoao commented 5 years ago

On Android:

case "BleDisconnectedException":
      throw BleDisconnectedException(message, details);

com.polidea.rxandroidble2.exceptions.BleDisconnectedException: Disconnected from MAC='XX:XX:XX:XX:XX:XX' with status 0 (GATT_SUCCESS) at com.polidea.rxandroidble2.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:80) at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:262) at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:770) at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:39) at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:257) at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:71) at android.os.Binder.execTransact(Binder.java:752)

01xJoao commented 5 years ago

The problem was I wasn't awaiting for the observeChar to be cancelled.