diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Constants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Constants.java index 003a9b7f4..5f44df90c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Constants.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Constants.java @@ -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; + } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Coordinator.java index a6e4e71ec..640766c3a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/tlw64/TLW64Coordinator.java @@ -136,6 +136,6 @@ public class TLW64Coordinator extends AbstractDeviceCoordinator { @Override public boolean supportsFindDevice() { - return false; + return true; } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java index fb50c0dc4..169d1741b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java @@ -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); + } + } }