mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-29 02:59:57 +02:00
@@ -409,6 +409,7 @@ public abstract class BluetoothCommunication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
stopLeScan();
|
||||||
connectGatt(device);
|
connectGatt(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,15 +456,20 @@ public abstract class BluetoothCommunication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopLeScan() {
|
||||||
|
if (leScanCallback != null) {
|
||||||
|
Timber.d("Stopping LE scan");
|
||||||
|
btAdapter.stopLeScan(leScanCallback);
|
||||||
|
leScanCallback = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect from a Bluetooth device
|
* Disconnect from a Bluetooth device
|
||||||
*/
|
*/
|
||||||
public void disconnect(boolean doCleanup) {
|
public void disconnect(boolean doCleanup) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (leScanCallback != null) {
|
stopLeScan();
|
||||||
btAdapter.stopLeScan(leScanCallback);
|
|
||||||
leScanCallback = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bluetoothGatt == null) {
|
if (bluetoothGatt == null) {
|
||||||
return;
|
return;
|
||||||
@@ -563,10 +569,7 @@ public abstract class BluetoothCommunication {
|
|||||||
|
|
||||||
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (leScanCallback != null) {
|
stopLeScan();
|
||||||
btAdapter.stopLeScan(leScanCallback);
|
|
||||||
leScanCallback = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionEstablished = true;
|
connectionEstablished = true;
|
||||||
|
Reference in New Issue
Block a user