1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-12 19:54:29 +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:
OliE
2019-03-19 19:28:35 +01:00
committed by GitHub
parent ce1ea8bf07
commit f24fc35059
3 changed files with 12 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ android {
} }
dependencies { 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.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0'
@@ -52,8 +52,8 @@ dependencies {
implementation 'com.j256.simplecsv:simplecsv:2.3' implementation 'com.j256.simplecsv:simplecsv:2.3'
// RxAndroidBle // RxAndroidBle
implementation 'com.polidea.rxandroidble2:rxandroidble:1.7.1' implementation 'com.polidea.rxandroidble2:rxandroidble:1.8.2'
implementation 'io.reactivex.rxjava2:rxjava:2.2.2' implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.jakewharton.rx2:replaying-share:2.1.0' implementation 'com.jakewharton.rx2:replaying-share:2.1.0'

View File

@@ -105,7 +105,7 @@ public class OpenScale {
fragmentList = new ArrayList<>(); fragmentList = new ArrayList<>();
bleClient = RxBleClient.create(context); bleClient = RxBleClient.create(context);
RxBleClient.setLogLevel(RxBleLog.DEBUG); RxBleClient.setLogLevel(RxBleLog.VERBOSE);
RxBleLog.setLogger((level, tag, msg) -> Timber.tag(tag).log(level, msg)); RxBleLog.setLogger((level, tag, msg) -> Timber.tag(tag).log(level, msg));
reopenDatabase(false); reopenDatabase(false);

View File

@@ -35,6 +35,7 @@ import com.polidea.rxandroidble2.scan.ScanSettings;
import java.io.IOException; import java.io.IOException;
import java.net.SocketException; import java.net.SocketException;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import io.reactivex.Observable; import io.reactivex.Observable;
@@ -69,6 +70,7 @@ public abstract class BluetoothCommunication {
protected Context context; protected Context context;
private final int BT_RETRY_TIMES_ON_ERROR = 3; private final int BT_RETRY_TIMES_ON_ERROR = 3;
private final int BT_DELAY_MS = 10;
private RxBleClient bleClient; private RxBleClient bleClient;
private RxBleDevice bleDevice; private RxBleDevice bleDevice;
@@ -239,6 +241,7 @@ public abstract class BluetoothCommunication {
.flatMapSingle(rxBleConnection -> rxBleConnection.writeCharacteristic(characteristic, bytes)) .flatMapSingle(rxBleConnection -> rxBleConnection.writeCharacteristic(characteristic, bytes))
.subscribeOn(Schedulers.trampoline()) .subscribeOn(Schedulers.trampoline())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
.retry(BT_RETRY_TIMES_ON_ERROR); .retry(BT_RETRY_TIMES_ON_ERROR);
compositeDisposable.add(observable.subscribe( compositeDisposable.add(observable.subscribe(
@@ -267,6 +270,7 @@ public abstract class BluetoothCommunication {
.flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(characteristic)) .flatMap(rxBleConnection -> rxBleConnection.readCharacteristic(characteristic))
.subscribeOn(Schedulers.trampoline()) .subscribeOn(Schedulers.trampoline())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
.retry(BT_RETRY_TIMES_ON_ERROR); .retry(BT_RETRY_TIMES_ON_ERROR);
compositeDisposable.add(observable compositeDisposable.add(observable
@@ -297,6 +301,7 @@ public abstract class BluetoothCommunication {
.flatMap(indicationObservable -> indicationObservable) .flatMap(indicationObservable -> indicationObservable)
.subscribeOn(Schedulers.trampoline()) .subscribeOn(Schedulers.trampoline())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
.retry(BT_RETRY_TIMES_ON_ERROR); .retry(BT_RETRY_TIMES_ON_ERROR);
compositeDisposable.add(observable.subscribe( compositeDisposable.add(observable.subscribe(
@@ -333,6 +338,7 @@ public abstract class BluetoothCommunication {
.flatMap(notificationObservable -> notificationObservable) .flatMap(notificationObservable -> notificationObservable)
.subscribeOn(Schedulers.trampoline()) .subscribeOn(Schedulers.trampoline())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
.retry(BT_RETRY_TIMES_ON_ERROR); .retry(BT_RETRY_TIMES_ON_ERROR);
compositeDisposable.add(observable.subscribe( compositeDisposable.add(observable.subscribe(
@@ -355,6 +361,7 @@ public abstract class BluetoothCommunication {
.flatMapSingle(RxBleConnection::discoverServices) .flatMapSingle(RxBleConnection::discoverServices)
.subscribeOn(Schedulers.trampoline()) .subscribeOn(Schedulers.trampoline())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.delay(BT_DELAY_MS, TimeUnit.MILLISECONDS)
.retry(BT_RETRY_TIMES_ON_ERROR); .retry(BT_RETRY_TIMES_ON_ERROR);
compositeDisposable.add(observable.subscribe( compositeDisposable.add(observable.subscribe(
@@ -520,7 +527,7 @@ public abstract class BluetoothCommunication {
resetDisconnectTimer(); resetDisconnectTimer();
} }
} }
}, 500); }, 1000);
} }
private void setBtMonitoringOn() { private void setBtMonitoringOn() {