mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 16:23:09 +02:00
Do gatt connect on main thread
This commit is contained in:
@@ -476,16 +476,21 @@ public abstract class BluetoothCommunication {
|
|||||||
private void startLeScanForDevice(final String hwAddress) {
|
private void startLeScanForDevice(final String hwAddress) {
|
||||||
leScanCallback = new BluetoothAdapter.LeScanCallback() {
|
leScanCallback = new BluetoothAdapter.LeScanCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
|
public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {
|
||||||
Timber.d("Found LE device %s [%s]", device.getName(), device.getAddress());
|
Timber.d("Found LE device %s [%s]", device.getName(), device.getAddress());
|
||||||
if (!device.getAddress().equals(hwAddress)) {
|
if (!device.getAddress().equals(hwAddress)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (lock) {
|
handler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (leScanCallback != null) {
|
||||||
stopLeScan();
|
stopLeScan();
|
||||||
connectGatt(device);
|
connectGatt(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Timber.d("Starting LE scan for device [%s]", hwAddress);
|
Timber.d("Starting LE scan for device [%s]", hwAddress);
|
||||||
|
Reference in New Issue
Block a user