1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-18 14:47:46 +01:00

TLW64: Support find device

This commit is contained in:
115ek 2020-06-30 09:32:44 +02:00
parent dfd2eb0e10
commit 7c5a2d0e58
3 changed files with 28 additions and 2 deletions

View File

@ -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_SERVICE_NO1 = UUID.fromString("000055ff-0000-1000-8000-00805f9b34fb");
public static final UUID UUID_CHARACTERISTIC_CONTROL = UUID.fromString("000033f1-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;
} }

View File

@ -136,6 +136,6 @@ public class TLW64Coordinator extends AbstractDeviceCoordinator {
@Override @Override
public boolean supportsFindDevice() { public boolean supportsFindDevice() {
return false; return true;
} }
} }

View File

@ -25,6 +25,7 @@ import android.net.Uri;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
@ -170,7 +171,9 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
@Override @Override
public void onFindDevice(boolean start) { public void onFindDevice(boolean start) {
if (start) {
setVibration(1, 3);
}
} }
@Override @Override
@ -222,4 +225,24 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
public void onSendWeather(WeatherSpec weatherSpec) { 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);
}
}
} }