mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-11 01:21:56 +01:00
Add more commands. Add message check function.
This commit is contained in:
parent
89c8c9cdfb
commit
c611042e51
@ -19,8 +19,46 @@ public class ZeTimeConstants {
|
||||
public static final UUID UUID_SERVICE_HEART_RATE = UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
public static final byte CMD_PREAMBLE = (byte) 0x6f;
|
||||
public static final byte CMD_GET_AVAIABLE_DATE = (byte) 0x52;
|
||||
// list all available commands
|
||||
public static final byte CMD_RESPOND = (byte) 0x01;
|
||||
public static final byte CMD_WATCH_ID = (byte) 0x02;
|
||||
public static final byte CMD_DEVICE_VERSION = (byte) 0x03;
|
||||
public static final byte CMD_DATE_TIME = (byte) 0x04;
|
||||
public static final byte CMD_TIME_SURFACE_SETTINGS = (byte) 0x05;
|
||||
public static final byte CMD_SURFACE_DISPLAY_SETTIGNS = (byte) 0x06;
|
||||
public static final byte CMD_SCREEN_BRIGHTNESS = (byte) 0x07;
|
||||
public static final byte CMD_BATTERY_POWER = (byte) 0x08;
|
||||
public static final byte CMD_VOLUME_SETTINGS = (byte) 0x09;
|
||||
public static final byte CMD_SHOCK_MODE = (byte) 0x0A;
|
||||
public static final byte CMD_LANGUAGE_SETTINGS = (byte) 0x0B;
|
||||
public static final byte CMD_UNIT_SETTINGS = (byte) 0x0C;
|
||||
public static final byte CMD_FACTORY_RESTORE = (byte) 0x0D;
|
||||
public static final byte CMD_ENTER_UPGRADE_MODE = (byte) 0x0E;
|
||||
public static final byte CMD_SHOCK_STRENGTH = (byte) 0x10;
|
||||
public static final byte CMD_WORK_MODE = (byte) 0x12;
|
||||
public static final byte CMD_SCREEN_ON_TIME = (byte) 0x13;
|
||||
public static final byte CMD_SNOOZE = (byte) 0x14;
|
||||
public static final byte CMD_DO_NOT_DISTURB = (byte) 0x15;
|
||||
public static final byte CMD_USER_INFO = (byte) 0x30;
|
||||
public static final byte CMD_USAGE_HABITS = (byte) 0x31;
|
||||
public static final byte CMD_USER_NAME = (byte) 0x32;
|
||||
public static final byte CMD_GOALS = (byte) 0x50;
|
||||
public static final byte CMD_AVAIABLE_DATA = (byte) 0x52;
|
||||
public static final byte CMD_DELETE_STEP_COUNT = (byte) 0x53;
|
||||
public static final byte CMD_GET_STEP_COUNT = (byte) 0x54;
|
||||
public static final byte CMD_DELETE_SLEEP_DATA = (byte) 0x55;
|
||||
public static final byte CMD_GET_SLEEP_DATA = (byte) 0x56;
|
||||
public static final byte CMD_DELETE_HEARTRATE_DATA = (byte) 0x5A;
|
||||
public static final byte CMD_GET_HEARTRATE_DATA = (byte) 0x5B;
|
||||
public static final byte CMD_AUTO_HEARTRATE = (byte) 0x5C;
|
||||
public static final byte CMD_HEARTRATE_ALARM_LIMITS = (byte) 0x5D;
|
||||
public static final byte CMD_INACTIVITY_ALERT = (byte) 0x5E;
|
||||
public static final byte CMD_CALORIES_TYPE = (byte) 0x60;
|
||||
public static final byte CMD_GET_HEARTRATE_EXDATA = (byte) 0x61;
|
||||
// here are the action commands
|
||||
public static final byte CMD_REQUEST = (byte) 0x70;
|
||||
public static final byte CMD_REQUEST_RESPOND = (byte) 0x80;
|
||||
// further commands
|
||||
public static final byte CMD_END = (byte) 0x8f;
|
||||
public static final byte CMD_ACK_WRITE = (byte) 0x03;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeConstants.CMD_AVAIABLE_DATA;
|
||||
|
||||
/**
|
||||
* Created by Kranz on 08.02.2018.
|
||||
*/
|
||||
@ -59,7 +61,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
// do this in a function
|
||||
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
|
||||
ZeTimeConstants.CMD_GET_AVAIABLE_DATE,
|
||||
CMD_AVAIABLE_DATA,
|
||||
ZeTimeConstants.CMD_REQUEST,
|
||||
0x01,
|
||||
0x00,
|
||||
@ -230,6 +232,11 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
if (ZeTimeConstants.UUID_ACK_CHARACTERISTIC.equals(characteristicUUID)) {
|
||||
byte[] data = characteristic.getValue();
|
||||
if(isMsgFormatOK(data)) {
|
||||
switch (data[1]) {
|
||||
case ZeTimeConstants.CMD_AVAIABLE_DATA:
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
LOG.info("Unhandled characteristic changed: " + characteristicUUID);
|
||||
@ -237,4 +244,24 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isMsgFormatOK(byte[] msg)
|
||||
{
|
||||
if(msg[0] == ZeTimeConstants.CMD_PREAMBLE)
|
||||
{
|
||||
if((msg[3] != 0) && (msg[4] != 0))
|
||||
{
|
||||
int payloadSize = msg[4] * 256 + msg[3];
|
||||
int msgLength = payloadSize + 6;
|
||||
if(msgLength == msg.length)
|
||||
{
|
||||
if(msg[msgLength - 1] == ZeTimeConstants.CMD_END)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user