mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-12 03:34:09 +02:00
Sanitas SBF70/SBF75 (GATT_INSUF_AUTHORIZATION) bug fix (#441)
set discovery/connect delay to one second and Bluetooth communication delay to 10ms
This commit is contained in:
@@ -40,7 +40,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha03'
|
||||
implementation 'com.google.android.material:material:1.1.0-alpha04'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
@@ -52,8 +52,8 @@ dependencies {
|
||||
implementation 'com.j256.simplecsv:simplecsv:2.3'
|
||||
|
||||
// RxAndroidBle
|
||||
implementation 'com.polidea.rxandroidble2:rxandroidble:1.7.1'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
|
||||
implementation 'com.polidea.rxandroidble2:rxandroidble:1.8.2'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
implementation 'com.jakewharton.rx2:replaying-share:2.1.0'
|
||||
|
||||
|
@@ -105,7 +105,7 @@ public class OpenScale {
|
||||
fragmentList = new ArrayList<>();
|
||||
bleClient = RxBleClient.create(context);
|
||||
|
||||
RxBleClient.setLogLevel(RxBleLog.DEBUG);
|
||||
RxBleClient.setLogLevel(RxBleLog.VERBOSE);
|
||||
RxBleLog.setLogger((level, tag, msg) -> Timber.tag(tag).log(level, msg));
|
||||
|
||||
reopenDatabase(false);
|
||||
|
@@ -35,6 +35,7 @@ import com.polidea.rxandroidble2.scan.ScanSettings;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import io.reactivex.Observable;
|
||||
@@ -69,6 +70,7 @@ public abstract class BluetoothCommunication {
|
||||
protected Context context;
|
||||
|
||||
private final int BT_RETRY_TIMES_ON_ERROR = 3;
|
||||
private final int BT_DELAY_MS = 10;
|
||||
|
||||
private RxBleClient bleClient;
|
||||
private RxBleDevice bleDevice;
|
||||
@@ -239,6 +241,7 @@ public abstract class BluetoothCommunication {
|
||||
.flatMapSingle(rxBleConnection -> rxBleConnection.writeCharacteristic(characteristic, bytes))
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
|
||||
.retry(BT_RETRY_TIMES_ON_ERROR);
|
||||
|
||||
compositeDisposable.add(observable.subscribe(
|
||||
@@ -267,6 +270,7 @@ public abstract class BluetoothCommunication {
|
||||
.flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(characteristic))
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
|
||||
.retry(BT_RETRY_TIMES_ON_ERROR);
|
||||
|
||||
compositeDisposable.add(observable
|
||||
@@ -297,6 +301,7 @@ public abstract class BluetoothCommunication {
|
||||
.flatMap(indicationObservable -> indicationObservable)
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
|
||||
.retry(BT_RETRY_TIMES_ON_ERROR);
|
||||
|
||||
compositeDisposable.add(observable.subscribe(
|
||||
@@ -333,6 +338,7 @@ public abstract class BluetoothCommunication {
|
||||
.flatMap(notificationObservable -> notificationObservable)
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
|
||||
.retry(BT_RETRY_TIMES_ON_ERROR);
|
||||
|
||||
compositeDisposable.add(observable.subscribe(
|
||||
@@ -355,6 +361,7 @@ public abstract class BluetoothCommunication {
|
||||
.flatMapSingle(RxBleConnection::discoverServices)
|
||||
.subscribeOn(Schedulers.trampoline())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
|
||||
.retry(BT_RETRY_TIMES_ON_ERROR);
|
||||
|
||||
compositeDisposable.add(observable.subscribe(
|
||||
@@ -520,7 +527,7 @@ public abstract class BluetoothCommunication {
|
||||
resetDisconnectTimer();
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
private void setBtMonitoringOn() {
|
||||
|
Reference in New Issue
Block a user