TLW64: Support find device

This commit is contained in:
115ek
2020-07-30 12:15:12 +02:00
parent dfd2eb0e10
commit 7c5a2d0e58
3 changed files with 28 additions and 2 deletions
@@ -24,4 +24,7 @@ public final class TLW64Constants {
public static final UUID UUID_SERVICE_NO1 = UUID.fromString("000055ff-0000-1000-8000-00805f9b34fb");
public static final UUID UUID_CHARACTERISTIC_CONTROL = UUID.fromString("000033f1-0000-1000-8000-00805f9b34fb");
// Command bytes
public static final byte CMD_ALARM = (byte) 0xab;
}
@@ -136,6 +136,6 @@ public class TLW64Coordinator extends AbstractDeviceCoordinator {
@Override
public boolean supportsFindDevice() {
return false;
return true;
}
}
@@ -25,6 +25,7 @@ import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.UUID;
@@ -170,7 +171,9 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
@Override
public void onFindDevice(boolean start) {
if (start) {
setVibration(1, 3);
}
}
@Override
@@ -222,4 +225,24 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
public void onSendWeather(WeatherSpec weatherSpec) {
}
private void setVibration(int duration, int count) {
try {
TransactionBuilder builder = performInitialized("vibrate");
byte[] msg = new byte[]{
TLW64Constants.CMD_ALARM,
0,
0,
0,
(byte) duration,
(byte) count,
7, // unknown, sniffed by original app
1
};
builder.write(ctrlCharacteristic, msg);
builder.queue(getQueue());
} catch (IOException e) {
LOG.warn("Unable to set vibration", e);
}
}
}