Comments (9)
So this is what I have to automatically try to connect to device after disconnect happens with 5 seconds delay:
rxBleDevice.establishConnection(context, false) // <-- autoConnect flag
.doOnError(throwable -> {
Log.d(TAG, "rxBleConnection doOnError: " + throwable);
})
.retryWhen(new Func1<Observable<? extends Throwable>, Observable<?>>() {
@Override
public Observable<?> call(Observable<? extends Throwable> errorNotification) {
return errorNotification
.flatMap(new Func1<Throwable, Observable<?>>() {
@Override
public Observable<?> call(Throwable throwable) {
Log.v(TAG, "connect retrying...");
return Observable.timer(5, TimeUnit.SECONDS);
}
});
}
})
.subscribe(rxBleConnection -> {
Log.d(TAG, "rxBleConnection: " + rxBleConnection);
});
from rxandroidble.
This is expected behavior. Once disconnected you need to establish the connection manually again. Why do you think that it should be anyway different?
from rxandroidble.
The library notifies you that the connection has been lost but you need to call establish connection again to reconnect. Is that the case?
from rxandroidble.
yes
from rxandroidble.
Sorry, misunderstood you.
I just call this code again when connection state change(disconnected) appear.
and nothing happened.
from rxandroidble.
Could you provide code sample and preferably logs from RxAndroidBle?
from rxandroidble.
Please look at sources: https://github.com/dlykoits/RxAndtoidBLESample.git
Steps to reproduce:
- press connect -> ble device connected
- then turn off ble device - > connection lost
- turn on ble device
- press connect
Actual result:
connection establishment doesn't work, "disconnected" status appear immediately after establish call
Expected result:
connection established again
from rxandroidble.
What I see is that you're trying to reuse a Subscriber here and that is a misuse as the Subscriber is stateful and therefore cannot be reused. It was already failed once and is probably unsubscribing automatically.
You can try either to create a new Subscriber for each subscription or to use an Observer instead - which is stateless.
from rxandroidble.
You right, Thanks a lot!!!
P.S.: I started learning RX week ago.
from rxandroidble.
Related Issues (20)
- Building fork help HOT 6
- It is not possible to disconnect the Bluetooth while it is in the process of connecting. HOT 1
- BleGattCharacteristicException while readCharacteristic HOT 12
- scanResult.bleDevice.name not showing Ble updated name HOT 1
- BLUETOOTH_SCAN set usesPermissionFlags="neverForLocation",Is there a problem? HOT 2
- GenericFailure<CharacteristicValueUpdateError> HOT 11
- Send long bytes twice HOT 2
- Write request is not processed in the random order HOT 2
- Long Bytes Send HOT 8
- Creating a Fork HOT 2
- Set Preferred PHY / Read PHY HOT 2
- RxBleClient mulit connections HOT 4
- Is the library still maintained? HOT 3
- Android 14 breaking change HOT 15
- Google Pixel 5 loses bonding info after BT adapter cycle HOT 4
- Metode readcharacteristic not stream HOT 2
- Unable to readCharacteristic after writeCharacteristic HOT 5
- In the case of unsuccessful Bluetooth connection, actively disconnect without executing context. unregisterReceiver (receiver); At this point, there may be multiple Bluetooth broadcast registrarReceivers, which may crash on some Huawei phones due to a broadcast limit of approximately 1000. Suggest fixing this issue. HOT 2
- Can't scan after connect dispose/clear HOT 1
- Add `advertisingSid` property to `ScanResult` and `RxBleInternalScanResult` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxandroidble.