1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

request activity info with a function.

This commit is contained in:
Sebastian Kranz 2018-06-24 12:25:34 +02:00
parent 65f12bc1ee
commit e18b043d27

View File

@ -64,15 +64,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
builder.notify(ackCharacteristic, true);
requestDeviceInfo(builder);
requestBatteryInfo(builder);
// do this in a function
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
CMD_AVAIABLE_DATA,
ZeTimeConstants.CMD_REQUEST,
0x01,
0x00,
0x00,
ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
requestActivityInfo(builder);
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
LOG.info("Initialization Done");
@ -247,6 +239,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.CMD_BATTERY_POWER:
handleBatteryInfo(data);
break;
case ZeTimeConstants.CMD_SHOCK_STRENGTH:
break;
case ZeTimeConstants.CMD_AVAIABLE_DATA:
break;
}
@ -314,6 +308,30 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
return this;
}
private ZeTimeDeviceSupport requestActivityInfo(TransactionBuilder builder) {
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_AVAIABLE_DATA,
ZeTimeConstants.CMD_REQUEST,
0x01,
0x00,
0x00,
ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
return this;
}
private ZeTimeDeviceSupport requestShockStrength(TransactionBuilder builder) {
builder.write(writeCharacteristic, new byte[]{ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_SHOCK_STRENGTH,
ZeTimeConstants.CMD_REQUEST,
0x01,
0x00,
0x00,
ZeTimeConstants.CMD_END});
builder.write(ackCharacteristic, new byte[]{ZeTimeConstants.CMD_ACK_WRITE});
return this;
}
private void handleBatteryInfo(byte[] value) {
batteryCmd.level = ((short) value[5]);
if(batteryCmd.level <= 25)