Failed to reconnect device after bluetooth disable
See original GitHub issueSummary
Failed to reconnect to a device after switch on the bluetooth. And on every device when bluetooth enable weird exception.
Library version
1.4.3
Preconditions
- Honor 8 or Gretel gt6000
Steps to reproduce actual result
1. Establish connection
2. Kill bluetooth
3. try to establish again connection
Minimum code snippet reproducing the issue
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val rxBleClient = RxBleClient.create(this)
val device = rxBleClient.getBleDevice("XX:XX:XX:XX:XX:XX")
button.setOnClickListener {
subscriptor = RxJavaInterop.toV2Observable(device?.establishConnection(false)?.doOnNext {
Log.i(TAG, "connected RX")
})?.subscribe({
Log.w(TAG, "connected")
}, {
Log.e(TAG, "error",it)
})
}
}
Logs from the application running with setting RxBleLog.setLogLevel(RxBleLog.VERBOSE)
First click :
02-20 18:22:08.471 8236-8236/com.example.testble D/MAIN: click
02-20 18:22:08.518 8236-8287/com.example.testble D/BluetoothGatt: connect() - device: XXXXXXXXXXXXXXXXXX, auto: false
registerApp()
02-20 18:22:08.519 8236-8287/com.example.testble D/BluetoothGatt: registerApp() - UUID=b46d98a3-c929-47b1-9737-c94b117d7f53
02-20 18:22:08.536 8236-8248/com.example.testble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
02-20 18:22:08.760 8236-8248/com.example.testble D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=5 device=XXXXXXXXXXXXXXXXXX
02-20 18:22:08.766 8236-8286/com.example.testble I/MAIN: connected RX
02-20 18:22:08.766 8236-8286/com.example.testble W/MAIN: connected
Disable bluetooth
When trying to connect after Bluetooth disable :
02-20 18:18:07.981 21761-21761/com.example.testble D/MAIN: click
02-20 18:18:08.026 21761-21915/com.example.testble D/BluetoothGatt: connect() - device: XXXXXXXXXXXXXXXXXX, auto: false
02-20 18:18:08.027 21761-21915/com.example.testble D/BluetoothGatt: registerApp()
registerApp() - UUID=63905fac-2e0b-4cbd-ad6e-87c11750d6b3
02-20 18:18:08.050 21761-21774/com.example.testble D/BluetoothGatt: onClientRegistered() - status=0 clientIf=7
02-20 18:18:38.068 21761-21774/com.example.testble D/BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=XXXXXXXXXXXXXXXXXX
02-20 18:18:38.095 21761-21774/com.example.testble E/MAIN: error
com.polidea.rxandroidble.exceptions.BleDisconnectedException: Disconnected from XXXXXXXXXXXXXXXXXX
at com.polidea.rxandroidble.internal.connection.RxBleGattCallback$2.onConnectionStateChange(RxBleGattCallback.java:76)
at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:191)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:70)
at android.os.Binder.execTransact(Binder.java:565)
02-20 18:18:38.291 21761-21766/com.example.testble I/art: Do partial code cache collection, code=29KB, data=26KB
After code cache collection, code=29KB, data=26KB
Increasing code cache capacity to 128KB
02-20 18:18:50.343 21761-21761/com.example.testble V/AudioManager: playSoundEffect effectType: 0
querySoundEffectsEnabled...
02-20 18:18:50.343 21761-21761/com.example.testble D/MAIN: click
02-20 18:18:50.344 21761-21761/com.example.testble E/MAIN: error
com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException: Already connected to device with MAC address XXXXXXXXXXXXXXXXXX
at com.polidea.rxandroidble.internal.RxBleDeviceImpl$1.call(RxBleDeviceImpl.java:80)
at com.polidea.rxandroidble.internal.RxBleDeviceImpl$1.call(RxBleDeviceImpl.java:67)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at hu.akarnokd.rxjava.interop.ObservableV1ToObservableV2.subscribeActual(ObservableV1ToObservableV2.java:37)
at io.reactivex.Observable.subscribe(Observable.java:10903)
at io.reactivex.Observable.subscribe(Observable.java:10889)
at io.reactivex.Observable.subscribe(Observable.java:10818)
at com.example.testble.MainActivity$onCreate$1.onClick(MainActivity.kt:54)
at android.view.View.performClick(View.java:5646)
at android.view.View$PerformClick.run(View.java:22473)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Actual result
Impossible to reconnect to the device even when we close the application.
The weird things is when I try to click (first time) why the Bluetooth disable I get :
02-20 18:29:50.594 10302-10302/com.example.testble D/MAIN: click
02-20 18:29:50.611 10302-10343/com.example.testble E/MAIN: error
com.polidea.rxandroidble.exceptions.BleDisconnectedException: Disconnected from XXXXXXXXXXXXXXXXXX
at com.polidea.rxandroidble.internal.connection.DisconnectionRouter$1.call(DisconnectionRouter.java:48)
at com.polidea.rxandroidble.internal.connection.DisconnectionRouter$1.call(DisconnectionRouter.java:45)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.internal.operators.OnSubscribeFilter$FilterSubscriber.onNext(OnSubscribeFilter.java:76)
at rx.observers.SerializedObserver.onNext(SerializedObserver.java:91)
at rx.observers.SerializedSubscriber.onNext(SerializedSubscriber.java:94)
at rx.internal.operators.OnSubscribeConcatMap$ConcatMapSubscriber.innerNext(OnSubscribeConcatMap.java:182)
at rx.internal.operators.OnSubscribeConcatMap$ConcatMapInnerScalarProducer.request(OnSubscribeConcatMap.java:366)
at rx.internal.producers.ProducerArbiter.setProducer(ProducerArbiter.java:126)
at rx.internal.operators.OnSubscribeConcatMap$ConcatMapSubscriber.drain(OnSubscribeConcatMap.java:278)
at rx.internal.operators.OnSubscribeConcatMap$ConcatMapSubscriber.onNext(OnSubscribeConcatMap.java:144)
at rx.internal.operators.OnSubscribeFromArray$FromArrayProducer.slowPath(OnSubscribeFromArray.java:100)
at rx.internal.operators.OnSubscribeFromArray$FromArrayProducer.request(OnSubscribeFromArray.java:63)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeFromArray.call(OnSubscribeFromArray.java:32)
at rx.internal.operators.OnSubscribeFromArray.call(OnSubscribeFromArray.java:24)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:94)
at rx.internal.operators.OnSubscribeConcatMap.call(OnSubscribeConcatMap.java:42)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeFilter.call(OnSubscribeFilter.java:45)
at rx.internal.operators.OnSubscribeFilter.call(OnSubscribeFilter.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:48)
at rx.internal.operators.OnSubscribeMap.call(OnSubscribeMap.java:33)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148)
at rx.internal.operators.OnSubscribeFromArray$FromArrayProducer.fastPath(OnSubscribeFromArray.java:76)
at rx.internal.operators.OnSubscribeFromArray$FromArrayProducer.request(OnSubscribeFromArray.java:58)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeFromArray.call(OnSubscribeFromArray.java:32)
at rx.internal.operators.OnSubscribeFromArray.call(OnSubscribeFromArray.java:24)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OperatorReplay.connect(OperatorReplay.java:310)
at rx.observables.ConnectableObservable.autoConnect(ConnectableObservable.java:125)
at rx.observables.ConnectableObservable.autoConnect(ConnectableObservable.java:105)
at com.polidea.rxandroidble.internal.connection.DisconnectionRouter.<init>(DisconnectionRouter.java:57)
at com.polidea.rxandroidble.internal.connection.DisconnectionRouter_Factory.get(DisconnectionRouter_Factory.java:36)
at com.polidea.rxandroidble.internal.connection.DisconnectionRouter_Factory.get(DisconnectionRouter_Factory.java:10)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble.internal.connection.RxBleGattCallback_Factory.get(RxBleGattCallback_Factory.java:37)
at com.polidea.rxandroidble.internal.connection.RxBleGattCallback_Factory.get(RxBleGattCallback_Factory.java:8)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.polidea.rxandroidble.internal.operations.ConnectOperation_Factory.get(ConnectOperation_Factory.java:65)
at com.polidea.rxandroidble.internal.operations.ConnectOperation_Factory.get(ConnectOperation_Factory.java:14)
at com.polidea.rxandroidble.DaggerClientComponent$DeviceComponentImpl$ConnectionComponentImpl.connectOperation(DaggerClientComponent.java:861)
at com.polidea.rxandroidble.internal.connection.ConnectorImpl$1.call(ConnectorImpl.java:54)
at com.polidea.rxandroidble.internal.connection.ConnectorImpl$1.call(ConnectorImpl.java:38)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at hu.akarnokd.rxjava.interop.ObservableV1ToObservableV2.subscribeActual(ObservableV1ToObservableV2.java:37)
at io.reactivex.Observable.subscribe(Observable.java:10903)
at io.reactivex.Observable.subscribe(Observable.java:10889)
at io.reactivex.Observable.subscribe(Observable.java:10818)
at com.example.testble.MainActivity$onCreate$1.onClick(MainActivity.kt:54)
at android.view.View.performClick(View.java:5646)
at android.view.View$PerformClick.run(View.java:22473)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
second time I get : (still Bluetooth off)
02-20 18:31:14.011 10302-10302/com.example.testble D/MAIN: click
02-20 18:31:14.012 10302-10302/com.example.testble E/MAIN: error
com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException: Already connected to device with MAC address XXXXXXXXXXXXXXXXXX
at com.polidea.rxandroidble.internal.RxBleDeviceImpl$1.call(RxBleDeviceImpl.java:80)
at com.polidea.rxandroidble.internal.RxBleDeviceImpl$1.call(RxBleDeviceImpl.java:67)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:10256)
at hu.akarnokd.rxjava.interop.ObservableV1ToObservableV2.subscribeActual(ObservableV1ToObservableV2.java:37)
at io.reactivex.Observable.subscribe(Observable.java:10903)
at io.reactivex.Observable.subscribe(Observable.java:10889)
at io.reactivex.Observable.subscribe(Observable.java:10818)
at com.example.testble.MainActivity$onCreate$1.onClick(MainActivity.kt:54)
at android.view.View.performClick(View.java:5646)
at android.view.View$PerformClick.run(View.java:22473)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Not only on the Honor is that normal ?
Expected result
To be able to turn on bluetooth and connect to the device again. And an other exception like Bluetooth Adapter not available
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (9 by maintainers)
Top Results From Across the Web
A Bluetooth mouse or keyboard fails to reconnect after being ...
Click on Device Manager. 3. In Device Manager, expand Bluetooth and select the Bluetooth radio. 4. Right-click on the Bluetooth radio and select...
Read more >Failed to reconnect device after bluetooth disable #376 - GitHub
Summary Failed to reconnect to a device after switch on the bluetooth. And on every device when bluetooth enable weird exception.
Read more >6 Ways to Troubleshoot If You Can't Remove a Bluetooth Device
To remedy that, open Settings in Windows 11 and click Bluetooth & devices. Then turn off Bluetooth by swiping the button to the...
Read more >Re:Unable to connect or remove old bluetooth devices after ...
Remove all entries (folder containing the Bluetooth name, if not possible just the file). I know this is risky - You need to...
Read more >Bluetooth fails to reconnect when bluetooth turned off then ...
Once an ACL between two Bluetooth devices is dropped, all profile communications would be stopped right away. The best solution for this issue...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @TimoPtr You can read more on the topic here: #318 Currently we have no solution that is bulletproof…
Good to hear that it is solved. You have incorrectly stated that the problem is on
1.4.3
versionClosing