diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java index fd5ce18d..f2a5f31e 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothCommunication.java @@ -521,11 +521,6 @@ public abstract class BluetoothCommunication { Timber.d("onConnectionStateChange: status=%d, newState=%d", status, newState); if (newState == BluetoothProfile.STATE_CONNECTED) { - if (leScanCallback != null) { - btAdapter.stopLeScan(leScanCallback); - leScanCallback = null; - } - connectionEstablished = true; setBtStatus(BT_STATUS_CODE.BT_CONNECTION_ESTABLISHED); gatt.discoverServices(); @@ -542,6 +537,11 @@ public abstract class BluetoothCommunication { public void onServicesDiscovered(final BluetoothGatt gatt, int status) { Timber.d("onServicesDiscovered: status=%d", status); + if (leScanCallback != null) { + btAdapter.stopLeScan(leScanCallback); + leScanCallback = null; + } + synchronized (lock) { cmdStepNr = 0; initStepNr = 0;