1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-18 22:41:44 +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 void onBluetoothDataChange(BluetoothGatt bluetoothGatt, BluetoothGattCharacteristic gattCharacteristic) {}
protected boolean doScanWhileConnecting() {
return true;
}
/** /**
* Set the Bluetooth machine state to a specific state. * Set the Bluetooth machine state to a specific state.
* *
@@ -455,6 +459,10 @@ public abstract class BluetoothCommunication {
private void connectGatt(BluetoothDevice device) { private void connectGatt(BluetoothDevice device) {
Timber.i("Connecting to [%s] (driver: %s)", device.getAddress(), driverName()); Timber.i("Connecting to [%s] (driver: %s)", device.getAddress(), driverName());
if (!doScanWhileConnecting()) {
stopLeScan();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
bluetoothGatt = device.connectGatt( bluetoothGatt = device.connectGatt(
context, false, gattCallback, BluetoothDevice.TRANSPORT_LE); context, false, gattCallback, BluetoothDevice.TRANSPORT_LE);

View File

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