Add SilenceAlertsCommand (untested)
This commit is contained in:
parent
1afc0ae2a9
commit
43c3b42912
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.BitSet;
|
||||
|
||||
public class SilenceAlertsCommand extends CommandBase {
|
||||
private static final short LENGTH = (short) 7;
|
||||
private static final byte BODY_LENGTH = (byte) 5;
|
||||
|
||||
private final SilenceAlertCommandParameters parameters;
|
||||
|
||||
public SilenceAlertsCommand(int address, short sequenceNumber, boolean unknown, SilenceAlertCommandParameters parameters) {
|
||||
super(CommandType.SILENCE_ALERTS, address, sequenceNumber, unknown);
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, LENGTH, unknown)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(1229869870) // FIXME ?? was: byte array of int 777211465 converted to little endian
|
||||
.put(parameters.getEncoded()) //
|
||||
.array());
|
||||
}
|
||||
|
||||
public static final class SilenceAlertCommandParameters {
|
||||
private final boolean silenceAutoOffAlert;
|
||||
private final boolean silenceMultiCommandAlert;
|
||||
private final boolean silenceExpirationImminentAlert;
|
||||
private final boolean silenceUserSetExpirationAlert;
|
||||
private final boolean silenceLowReservoirAlert;
|
||||
private final boolean silenceSuspendInProgressAlert;
|
||||
private final boolean silenceSuspendEndedAlert;
|
||||
private final boolean silencePodExpirationAlert;
|
||||
|
||||
public SilenceAlertCommandParameters(boolean silenceAutoOffAlert, boolean silenceMultiCommandAlert, boolean silenceExpirationImminentAlert, boolean silenceUserSetExpirationAlert, boolean silenceLowReservoirAlert, boolean silenceSuspendInProgressAlert, boolean silenceSuspendEndedAlert, boolean silencePodExpirationAlert) {
|
||||
this.silenceAutoOffAlert = silenceAutoOffAlert;
|
||||
this.silenceMultiCommandAlert = silenceMultiCommandAlert;
|
||||
this.silenceExpirationImminentAlert = silenceExpirationImminentAlert;
|
||||
this.silenceUserSetExpirationAlert = silenceUserSetExpirationAlert;
|
||||
this.silenceLowReservoirAlert = silenceLowReservoirAlert;
|
||||
this.silenceSuspendInProgressAlert = silenceSuspendInProgressAlert;
|
||||
this.silenceSuspendEndedAlert = silenceSuspendEndedAlert;
|
||||
this.silencePodExpirationAlert = silencePodExpirationAlert;
|
||||
}
|
||||
|
||||
public byte[] getEncoded() {
|
||||
BitSet bitSet = new BitSet(8);
|
||||
bitSet.set(0, this.silenceAutoOffAlert);
|
||||
bitSet.set(1, this.silenceMultiCommandAlert);
|
||||
bitSet.set(2, this.silenceExpirationImminentAlert);
|
||||
bitSet.set(3, this.silenceUserSetExpirationAlert);
|
||||
bitSet.set(4, this.silenceLowReservoirAlert);
|
||||
bitSet.set(5, this.silenceSuspendInProgressAlert);
|
||||
bitSet.set(6, this.silenceSuspendEndedAlert);
|
||||
bitSet.set(7, this.silencePodExpirationAlert);
|
||||
return bitSet.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition;
|
||||
|
||||
public enum AlertSlot {
|
||||
AUTO_OFF((byte) 0x00),
|
||||
MULTI_COMMAND((byte) 0x01),
|
||||
EXPIRATION_IMMINENT((byte) 0x02),
|
||||
USER_SET_EXPIRATION((byte) 0x03),
|
||||
LOW_RESERVOIR((byte) 0x04),
|
||||
USER_POD_EXPIRATION((byte) 0x03),
|
||||
LUMP_OF_COAL_AND_EXPIRATION((byte) 0x07),
|
||||
UNKNOWN((byte) 255);
|
||||
SUSPEND_IN_PROGRESS((byte) 0x05),
|
||||
SUSPEND_ENDED((byte) 0x06),
|
||||
EXPIRATION((byte) 0x07),
|
||||
UNKNOWN((byte) 0xff);
|
||||
|
||||
private byte value;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ProgramAlertsCommandTest {
|
|||
@Test
|
||||
public void testExpirationAlerts() throws DecoderException {
|
||||
List<AlertConfiguration> configurations = new ArrayList<>();
|
||||
configurations.add(new AlertConfiguration(AlertSlot.LUMP_OF_COAL_AND_EXPIRATION, true, (short) 420, false, AlertTriggerType.TIME_TRIGGER, (short) 4305, BeepType.XXX, BeepRepetitionType.XXX3));
|
||||
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 420, false, AlertTriggerType.TIME_TRIGGER, (short) 4305, BeepType.XXX, BeepRepetitionType.XXX3));
|
||||
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4725, BeepType.XXX, BeepRepetitionType.XXX4));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand(37879811, (short) 3, true, configurations).getEncoded();
|
||||
|
@ -40,7 +40,7 @@ public class ProgramAlertsCommandTest {
|
|||
@Test
|
||||
public void testUserExpirationAlert() throws DecoderException {
|
||||
List<AlertConfiguration> configurations = new ArrayList<>();
|
||||
configurations.add(new AlertConfiguration(AlertSlot.USER_POD_EXPIRATION, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4079, BeepType.XXX, BeepRepetitionType.XXX2));
|
||||
configurations.add(new AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4079, BeepType.XXX, BeepRepetitionType.XXX2));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand(37879811, (short) 15, false, configurations).getEncoded();
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class ProgramAlertsCommandTest {
|
|||
@Test
|
||||
public void testLumpOfCoalAlert() throws DecoderException {
|
||||
List<AlertConfiguration> configurations = new ArrayList<>();
|
||||
configurations.add(new AlertConfiguration(AlertSlot.LUMP_OF_COAL_AND_EXPIRATION, true, (short) 55, false, AlertTriggerType.TIME_TRIGGER, (short) 5, BeepType.XXX, BeepRepetitionType.XXX5));
|
||||
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 55, false, AlertTriggerType.TIME_TRIGGER, (short) 5, BeepType.XXX, BeepRepetitionType.XXX5));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand(37879811, (short) 10, false, configurations).getEncoded();
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command;
|
||||
|
||||
// TODO capture silence alerts command
|
||||
public class SilenceAlertsCommandTest {
|
||||
}
|
Loading…
Reference in a new issue