mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-26 03:46:49 +01:00
Zepp OS: Add code to toggle raw sensor data
This commit is contained in:
parent
fbd8b91e7f
commit
d77a32a430
@ -188,4 +188,11 @@ public class Huami2021Service {
|
||||
public static final byte USER_INFO_CMD_SET = 0x01;
|
||||
public static final byte USER_INFO_CMD_SET_ACK = 0x02;
|
||||
|
||||
/**
|
||||
* Raw sensor control.
|
||||
*/
|
||||
public static final byte[] CMD_RAW_SENSOR_START_1 = new byte[]{0x01, 0x03, 0x19}; // band replies 10:01:03:05
|
||||
public static final byte[] CMD_RAW_SENSOR_START_2 = new byte[]{0x01, 0x03, 0x00, 0x00, 0x00, 0x19}; // band replies 10:01:01:05
|
||||
public static final byte[] CMD_RAW_SENSOR_START_3 = new byte[]{0x02}; // band replies 10:02:01
|
||||
public static final byte[] CMD_RAW_SENSOR_STOP = new byte[]{0x03}; // band replies 10:03:01
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ public class HuamiService {
|
||||
public static final UUID UUID_CHARACTERISTIC_FIRMWARE_DATA = UUID.fromString("00001532-0000-3512-2118-0009af100700");
|
||||
|
||||
public static final UUID UUID_UNKNOWN_CHARACTERISTIC0 = UUID.fromString("00000000-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_RAW_SENSOR_CONTROL = UUID.fromString("00000001-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_RAW_SENSOR_DATA = UUID.fromString("00000002-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_CHARACTERISTIC_RAW_SENSOR_CONTROL = UUID.fromString("00000001-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_CHARACTERISTIC_RAW_SENSOR_DATA = UUID.fromString("00000002-0000-3512-2118-0009af100700");
|
||||
|
||||
/**
|
||||
* Alarms, Display and other configuration.
|
||||
|
@ -1191,6 +1191,30 @@ public abstract class Huami2021Support extends HuamiSupport {
|
||||
return (Huami2021Coordinator) DeviceHelper.getInstance().getCoordinator(gbDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRawSensor(final boolean enable) {
|
||||
LOG.info("Set raw sensor to {}", enable);
|
||||
try {
|
||||
final TransactionBuilder builder = performInitialized("set raw sensor");
|
||||
if (enable) {
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_CONTROL), Huami2021Service.CMD_RAW_SENSOR_START_1);
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_CONTROL), Huami2021Service.CMD_RAW_SENSOR_START_2);
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_CONTROL), Huami2021Service.CMD_RAW_SENSOR_START_3);
|
||||
} else {
|
||||
builder.write(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_CONTROL), Huami2021Service.CMD_RAW_SENSOR_STOP);
|
||||
}
|
||||
builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_DATA), enable);
|
||||
builder.queue(getQueue());
|
||||
} catch (final IOException e) {
|
||||
LOG.error("Unable to set raw sensor", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleRawSensorData(final byte[] value) {
|
||||
LOG.debug("Raw sensor: {}", GB.hexdump(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle2021Payload(final short type, final byte[] payload) {
|
||||
if (payload == null || payload.length == 0) {
|
||||
|
@ -2296,6 +2296,9 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
} else if (HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ.equals(characteristicUUID) && huami2021ChunkedDecoder != null) {
|
||||
huami2021ChunkedDecoder.decode(characteristic.getValue());
|
||||
return true;
|
||||
} else if (HuamiService.UUID_CHARACTERISTIC_RAW_SENSOR_DATA.equals(characteristicUUID)) {
|
||||
handleRawSensorData(characteristic.getValue());
|
||||
return true;
|
||||
} else {
|
||||
LOG.info("Unhandled characteristic changed: " + characteristicUUID);
|
||||
logMessageContent(characteristic.getValue());
|
||||
@ -4229,4 +4232,12 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRawSensor(final boolean enable) {
|
||||
LOG.info("setRawSensor not implemented for HuamiSupport");
|
||||
}
|
||||
|
||||
protected void handleRawSensorData(final byte[] value) {
|
||||
LOG.warn("handleRawSensorData not implemented for HuamiSupport");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user