Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce operation viability checks prior to execution #224

Closed
dariuszseweryn opened this issue Jun 19, 2017 · 1 comment
Closed

Introduce operation viability checks prior to execution #224

dariuszseweryn opened this issue Jun 19, 2017 · 1 comment
Assignees
Milestone

Comments

@dariuszseweryn
Copy link
Owner

Summary

Sometimes user tries to execute an operation of type that is not supported by a characteristic which ends with not easily understandable error like BluetoothGattException with some status code.

Preconditions

A characteristic that only supports indications.

Steps to reproduce actual result


1. Connect to a device

2. Discover services

3. Setup notifications on the characteristic

4. Observe error with status=128

Logs from the application running with setting RxBleLog.setLogLevel(RxBleLog.VERBOSE)

06-18 17:44:56.316 19237-19258/com.mypackage D/RxBle#BluetoothGatt: onServicesDiscovered status=0
06-18 17:44:56.316 19237-19319/com.mypackage D/BluetoothGatt: setCharacteristicNotification() - uuid: 18cda784-4bd3-4370-85bb-bfed91ec86af enable: true
06-18 17:44:56.321 19237-19319/com.mypackage D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(1110660456)
06-18 17:44:56.321 19237-19250/com.mypackage D/RxBle#Radio: FINISHED RxBleRadioOperationServicesDiscover(1110487864)
06-18 17:44:56.321 19237-19250/com.mypackage D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(1110660456)
06-18 17:44:56.346 19237-19237/com.mypackage D/BluetoothGatt: writeDescriptor() - uuid: 00002902-0000-1000-8000-00805f9b34fb
06-18 17:44:56.726 19237-19249/com.mypackage D/BluetoothGatt: onDescriptorWrite() - Device=EC:FE:7E:15:91:3A UUID=18cda784-4bd3-4370-85bb-bfed91ec86af
06-18 17:44:56.731 19237-19249/com.mypackage D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=128
06-18 17:44:56.736 19237-19250/com.mypackage D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(1110660456)
06-18 17:44:56.736 19237-19319/com.mypackage D/BluetoothGatt: setCharacteristicNotification() - uuid: 18cda784-4bd3-4370-85bb-bfed91ec86af enable: false
06-18 17:44:56.741 19237-19319/com.mypackage D/RxBle#Radio:   QUEUED RxBleRadioOperationDescriptorWrite(1110764936)
06-18 17:44:56.741 19237-19250/com.mypackage D/RxBle#Radio:  STARTED RxBleRadioOperationDescriptorWrite(1110764936)
06-18 17:44:56.746 19237-19237/com.mypackage D/BluetoothGatt: writeDescriptor() - uuid: 00002902-0000-1000-8000-00805f9b34fb
06-18 17:44:56.771 19237-19319/com.mypackage D/dalvikvm: GC_FOR_ALLOC freed 1369K, 30% free 6034K/8532K, paused 19ms, total 19ms
06-18 17:44:56.771 19237-19319/com.mypackage E/TimeActivity: Error
                                                                     BleCannotSetCharacteristicNotificationException{bluetoothGattCharacteristic=18cda784-4bd3-4370-85bb-bfed91ec86af, reason=CANNOT_WRITE_CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR (see Javadoc for more comment)}
                                                                         at com.polidea.rxandroidble.internal.connection.NotificationAndIndicationManager$10.call(NotificationAndIndicationManager.java:215)
                                                                         at com.polidea.rxandroidble.internal.connection.NotificationAndIndicationManager$10.call(NotificationAndIndicationManager.java:212)
                                                                         at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140)
                                                                         at rx.internal.operators.OperatorMerge$MergeSubscriber.reportError(OperatorMerge.java:266)
                                                                         at rx.internal.operators.OperatorMerge$MergeSubscriber.checkTerminate(OperatorMerge.java:818)
                                                                         at rx.internal.operators.OperatorMerge$MergeSubscriber.emitLoop(OperatorMerge.java:579)
                                                                         at rx.internal.operators.OperatorMerge$MergeSubscriber.emit(OperatorMerge.java:568)
                                                                         at rx.internal.operators.OperatorMerge$InnerSubscriber.onError(OperatorMerge.java:852)
                                                                         at rx.internal.operators.OnSubscribeCreate$BaseEmitter.onError(OnSubscribeCreate.java:109)
                                                                         at rx.internal.util.ObserverSubscriber.onError(ObserverSubscriber.java:39)
                                                                         at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153)
                                                                         at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115)
                                                                         at rx.internal.operators.OperatorUnsubscribeOn$1.onError(OperatorUnsubscribeOn.java:47)
                                                                         at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.onError(OperatorSubscribeOn.java:80)
                                                                         at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
                                                                         at rx.internal.operators.OnSubscribeCreate$BaseEmitter.onError(OnSubscribeCreate.java:109)
                                                                         at com.polidea.rxandroidble.internal.util.RadioReleasingEmitterWrapper.onError(RadioReleasingEmitterWrapper.java:44)
                                                                         at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153)
                                                                         at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115)
                                                                         at rx.observers.SerializedObserver.onError(SerializedObserver.java:152)
                                                                         at rx.observers.SerializedSubscriber.onError(SerializedSubscriber.java:78)
                                                                         at rx.internal.operators.OperatorTimeoutBase$TimeoutSubscriber.onError(OperatorTimeoutBase.java:147)
                                                                         at rx.internal.operators.OperatorSingle$ParentSubscriber.onError(OperatorSingle.java:129)
                                                                         at rx.internal.operators.OperatorTake$1.onError(OperatorTake.java:65)
                                                                         at rx.internal.operators.OnSubscribeMap$MapSubscriber.onError(OnSubscribeMap.java:88)
                                                                         at rx.internal.operators.OnSubscribeFilter$FilterSubscriber.onError(OnSubscribeFilter.java:90)
                                                                         at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:273)
                                                                         at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216)
                                                                         at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                                                                         at rx.internal.schedulers.ExecutorScheduler$ExecutorSchedulerWorker.run(ExecutorScheduler.java:107)
                                                                         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                         at java.lang.Thread.run(Thread.java:841)
06-18 17:44:56.776 19237-19319/com.mypackage D/RxBle#Radio:   QUEUED RxBleRadioOperationDisconnect(1110319560)
06-18 17:44:56.826 19237-19258/com.mypackage D/BluetoothGatt: onDescriptorWrite() - Device=EC:FE:7E:15:91:3A UUID=18cda784-4bd3-4370-85bb-bfed91ec86af
06-18 17:44:56.826 19237-19258/com.mypackage D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=0
06-18 17:44:56.826 19237-19250/com.mypackage D/RxBle#Radio: FINISHED RxBleRadioOperationDescriptorWrite(1110764936)
06-18 17:44:56.826 19237-19250/com.mypackage D/RxBle#Radio:  STARTED RxBleRadioOperationDisconnect(1110319560)
06-18 17:44:56.831 19237-19237/com.mypackage D/BluetoothManager: getConnectionState()
06-18 17:44:56.831 19237-19237/com.mypackage D/BluetoothManager: getConnectedDevices
06-18 17:44:56.831 19237-19237/com.mypackage D/BluetoothGatt: cancelOpen() - device: EC:FE:7E:15:91:3A
06-18 17:44:56.836 19237-19248/com.mypackage D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=EC:FE:7E:15:91:3A
06-18 17:44:56.836 19237-19248/com.mypackage D/RxBle#BluetoothGatt: onConnectionStateChange newState=0 status=0
06-18 17:44:56.836 19237-19237/com.mypackage D/BluetoothGatt: close()
06-18 17:44:56.836 19237-19237/com.mypackage D/BluetoothGatt: unregisterApp() - mClientIf=5
06-18 17:44:56.836 19237-19250/com.mypackage D/RxBle#Radio: FINISHED RxBleRadioOperationDisconnect(1110319560)

Actual result

06-18 17:44:56.731 19237-19249/com.mypackage D/RxBle#BluetoothGatt: onDescriptorWrite descriptor=00002902-0000-1000-8000-00805f9b34fb status=128

Expected result

Easily understandable error

@dariuszseweryn dariuszseweryn added this to the 1.4.0 milestone Jun 20, 2017
dariuszseweryn pushed a commit that referenced this issue Aug 3, 2017
Implemented a mechanism for checking whether the requested characteristic operation can succeed. The check is based upon the properties of the chosen characteristic. End user can opt-out of the 'hard' way of checking (ie. throwing an exception) using new connection setup API.
dariuszseweryn added a commit that referenced this issue Aug 3, 2017
…lishConnection(SetupOptions)`

(#240 #224) This new function is a perfect extension point to introduce a new public API #239 which will return the new API without changing the Major version number. Till then all new public classes were moved to the `internal` package and should not be publicly available.
@dariuszseweryn
Copy link
Owner Author

The viability check will result in a log warning in 1.4.0. With the new connection API #239 it will be emitting an error by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants