1
0
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:
Erik Johansson
2018-10-07 09:24:37 +02:00
parent e6f0613c7a
commit f2197c9ca9

View File

@@ -476,16 +476,21 @@ public abstract class BluetoothCommunication {
private void startLeScanForDevice(final String hwAddress) {
leScanCallback = new BluetoothAdapter.LeScanCallback() {
@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());
if (!device.getAddress().equals(hwAddress)) {
return;
}
synchronized (lock) {
handler.post(new Runnable() {
@Override
public void run() {
if (leScanCallback != null) {
stopLeScan();
connectGatt(device);
}
}
});
}
};
Timber.d("Starting LE scan for device [%s]", hwAddress);