1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-18 06:21:25 +02:00

Stop scan before connecting to Medisana

Fixes #353 (hopefully)
This commit is contained in:
Erik Johansson
2018-11-24 22:40:41 +01:00
parent 4d09351f4a
commit 559d17678c
2 changed files with 14 additions and 0 deletions

View File

@@ -227,6 +227,10 @@ public abstract class BluetoothCommunication {
*/
protected void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {}
protected boolean doScanWhileConnecting() {
return true;
}
/**
* Set the Bluetooth machine state to a specific state.
*
@@ -455,6 +459,10 @@ public abstract class BluetoothCommunication {
private void connectGatt(BluetoothDevice device) {
Timber.i("Connecting to [%s] (driver: %s)", device.getAddress(), driverName());
if (!doScanWhileConnecting()) {
stopLeScan();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
bluetoothGatt = device.connectGatt(
context, false, gattCallback, BluetoothDevice.TRANSPORT_LE);

View File

@@ -47,6 +47,12 @@ public class BluetoothMedisanaBS44x extends BluetoothCommunication {
return "Medisana BS44x";
}
@Override
protected boolean doScanWhileConnecting() {
// Medisana seems to have problem connecting if scan is running (see #278 and #353)
return false;
}
@Override
protected boolean nextInitCmd(int stateNr) {
return false;