1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-21 07:51:46 +02:00

Stop LE scan when services have been discovered

Let us see if this improves #252
This commit is contained in:
Erik Johansson
2018-05-03 16:56:00 +02:00
parent 8706cd5884
commit d9b8c6253f

View File

@@ -521,11 +521,6 @@ public abstract class BluetoothCommunication {
Timber.d("onConnectionStateChange: status=%d, newState=%d", status, newState); Timber.d("onConnectionStateChange: status=%d, newState=%d", status, newState);
if (newState == BluetoothProfile.STATE_CONNECTED) { if (newState == BluetoothProfile.STATE_CONNECTED) {
if (leScanCallback != null) {
btAdapter.stopLeScan(leScanCallback);
leScanCallback = null;
}
connectionEstablished = true; connectionEstablished = true;
setBtStatus(BT_STATUS_CODE.BT_CONNECTION_ESTABLISHED); setBtStatus(BT_STATUS_CODE.BT_CONNECTION_ESTABLISHED);
gatt.discoverServices(); gatt.discoverServices();
@@ -542,6 +537,11 @@ public abstract class BluetoothCommunication {
public void onServicesDiscovered(final BluetoothGatt gatt, int status) { public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
Timber.d("onServicesDiscovered: status=%d", status); Timber.d("onServicesDiscovered: status=%d", status);
if (leScanCallback != null) {
btAdapter.stopLeScan(leScanCallback);
leScanCallback = null;
}
synchronized (lock) { synchronized (lock) {
cmdStepNr = 0; cmdStepNr = 0;
initStepNr = 0; initStepNr = 0;