mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 14:31:23 +02:00
adding a delay of 500 ms between the end of the BLE scan and the beginning of a connection
This commit is contained in:
@@ -517,28 +517,35 @@ public abstract class BluetoothCommunication {
|
|||||||
Timber.d("Stop Le san");
|
Timber.d("Stop Le san");
|
||||||
scanSubscription.dispose();
|
scanSubscription.dispose();
|
||||||
scanSubscription = null;
|
scanSubscription = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.d("Try to connect to BLE device " + macAddress);
|
Handler handler = new Handler();
|
||||||
|
handler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Timber.d("Try to connect to BLE device " + macAddress);
|
||||||
|
|
||||||
connectionObservable = bleDevice
|
connectionObservable = bleDevice
|
||||||
.establishConnection(false)
|
.establishConnection(false)
|
||||||
.delay(BT_DELAY, TimeUnit.MILLISECONDS)
|
.delay(BT_DELAY, TimeUnit.MILLISECONDS)
|
||||||
.takeUntil(disconnectTriggerSubject)
|
.takeUntil(disconnectTriggerSubject)
|
||||||
.doOnError(throwable -> setBtStatus(BT_STATUS_CODE.BT_CONNECTION_RETRYING))
|
.doOnError(throwable -> setBtStatus(BT_STATUS_CODE.BT_CONNECTION_RETRYING))
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.compose(ReplayingShare.instance());
|
.compose(ReplayingShare.instance());
|
||||||
|
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
disconnect();
|
disconnect();
|
||||||
} else {
|
} else {
|
||||||
initStepNr = -1;
|
initStepNr = -1;
|
||||||
cmdStepNr = -1;
|
cmdStepNr = -1;
|
||||||
cleanupStepNr = -1;
|
cleanupStepNr = -1;
|
||||||
|
|
||||||
setBtMonitoringOn();
|
setBtMonitoringOn();
|
||||||
setBtMachineState(BT_MACHINE_STATE.BT_INIT_STATE);
|
setBtMachineState(BT_MACHINE_STATE.BT_INIT_STATE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBtMonitoringOn() {
|
private void setBtMonitoringOn() {
|
||||||
|
Reference in New Issue
Block a user