Rename Omnipod Dash address to uniqueId
This commit is contained in:
parent
79c9e9a938
commit
8d554fa35b
17 changed files with 71 additions and 67 deletions
|
@ -10,13 +10,13 @@ public final class DeactivateCommand extends NonceEnabledCommand {
|
|||
private static final short LENGTH = 6;
|
||||
private static final byte BODY_LENGTH = 4;
|
||||
|
||||
DeactivateCommand(int address, short sequenceNumber, boolean multiCommandFlag, int nonce) {
|
||||
super(CommandType.DEACTIVATE, address, sequenceNumber, multiCommandFlag, nonce);
|
||||
DeactivateCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, int nonce) {
|
||||
super(CommandType.DEACTIVATE, uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(nonce) //
|
||||
|
@ -25,8 +25,9 @@ public final class DeactivateCommand extends NonceEnabledCommand {
|
|||
|
||||
@Override public String toString() {
|
||||
return "DeactivateCommand{" +
|
||||
"commandType=" + commandType +
|
||||
", address=" + address +
|
||||
"nonce=" + nonce +
|
||||
", commandType=" + commandType +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -34,7 +35,7 @@ public final class DeactivateCommand extends NonceEnabledCommand {
|
|||
|
||||
public static final class Builder extends NonceEnabledCommandBuilder<Builder, DeactivateCommand> {
|
||||
@Override protected final DeactivateCommand buildCommand() {
|
||||
return new DeactivateCommand(Builder.this.address, sequenceNumber, multiCommandFlag, nonce);
|
||||
return new DeactivateCommand(uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,28 +7,28 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.HeaderEnabledCommandBuilder;
|
||||
|
||||
public final class GetVersionCommand extends HeaderEnabledCommand {
|
||||
public static final int DEFAULT_ADDRESS = -1; // FIXME move
|
||||
public static final int DEFAULT_UNIQUE_ID = -1; // FIXME move
|
||||
|
||||
private static final short LENGTH = 6;
|
||||
private static final byte BODY_LENGTH = 4;
|
||||
|
||||
GetVersionCommand(int address, short sequenceNumber, boolean multiCommandFlag) {
|
||||
super(CommandType.GET_VERSION, address, sequenceNumber, multiCommandFlag);
|
||||
GetVersionCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag) {
|
||||
super(CommandType.GET_VERSION, uniqueId, sequenceNumber, multiCommandFlag);
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(address) //
|
||||
.putInt(uniqueId) //
|
||||
.array());
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "GetVersionCommand{" +
|
||||
"commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -36,7 +36,7 @@ public final class GetVersionCommand extends HeaderEnabledCommand {
|
|||
|
||||
public static final class Builder extends HeaderEnabledCommandBuilder<Builder, GetVersionCommand> {
|
||||
@Override protected final GetVersionCommand buildCommand() {
|
||||
return new GetVersionCommand(address, sequenceNumber, multiCommandFlag);
|
||||
return new GetVersionCommand(uniqueId, sequenceNumber, multiCommandFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
|
|||
public final class ProgramAlertsCommand extends NonceEnabledCommand {
|
||||
private final List<AlertConfiguration> alertConfigurations;
|
||||
|
||||
ProgramAlertsCommand(int address, short sequenceNumber, boolean multiCommandFlag, List<AlertConfiguration> alertConfigurations, int nonce) {
|
||||
super(CommandType.PROGRAM_ALERTS, address, sequenceNumber, multiCommandFlag, nonce);
|
||||
ProgramAlertsCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, List<AlertConfiguration> alertConfigurations, int nonce) {
|
||||
super(CommandType.PROGRAM_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
this.alertConfigurations = new ArrayList<>(alertConfigurations);
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(getLength() + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, getLength(), multiCommandFlag)) //
|
||||
.put(encodeHeader(uniqueId, sequenceNumber, getLength(), multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(getBodyLength()) //
|
||||
.putInt(nonce);
|
||||
|
@ -40,8 +40,9 @@ public final class ProgramAlertsCommand extends NonceEnabledCommand {
|
|||
@Override public String toString() {
|
||||
return "ProgramAlertsCommand{" +
|
||||
"alertConfigurations=" + alertConfigurations +
|
||||
", nonce=" + nonce +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -59,7 +60,7 @@ public final class ProgramAlertsCommand extends NonceEnabledCommand {
|
|||
if (this.alertConfigurations == null) {
|
||||
throw new IllegalArgumentException("alertConfigurations can not be null");
|
||||
}
|
||||
return new ProgramAlertsCommand(address, sequenceNumber, multiCommandFlag, alertConfigurations, nonce);
|
||||
return new ProgramAlertsCommand(uniqueId, sequenceNumber, multiCommandFlag, alertConfigurations, nonce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public final class ProgramBasalCommand extends HeaderEnabledCommand {
|
|||
private final short remainingTenthPulsesInCurrentInsulinProgramElement;
|
||||
private final int delayUntilNextTenthPulseInUsec;
|
||||
|
||||
ProgramBasalCommand(ProgramInsulinCommand interlockCommand, int address, short sequenceNumber, boolean multiCommandFlag, List<LongInsulinProgramElement> insulinProgramElements, ProgramReminder programReminder, byte currentInsulinProgramElementIndex, short remainingTenthPulsesInCurrentInsulinProgramElement, int delayUntilNextTenthPulseInUsec) {
|
||||
super(CommandType.PROGRAM_BASAL, address, sequenceNumber, multiCommandFlag);
|
||||
ProgramBasalCommand(ProgramInsulinCommand interlockCommand, int uniqueId, short sequenceNumber, boolean multiCommandFlag, List<LongInsulinProgramElement> insulinProgramElements, ProgramReminder programReminder, byte currentInsulinProgramElementIndex, short remainingTenthPulsesInCurrentInsulinProgramElement, int delayUntilNextTenthPulseInUsec) {
|
||||
super(CommandType.PROGRAM_BASAL, uniqueId, sequenceNumber, multiCommandFlag);
|
||||
|
||||
this.interlockCommand = interlockCommand;
|
||||
this.insulinProgramElements = new ArrayList<>(insulinProgramElements);
|
||||
|
@ -58,7 +58,7 @@ public final class ProgramBasalCommand extends HeaderEnabledCommand {
|
|||
|
||||
byte[] bolusCommand = buffer.array();
|
||||
byte[] interlockCommand = this.interlockCommand.getEncoded();
|
||||
byte[] header = encodeHeader(address, sequenceNumber, (short) (bolusCommand.length + interlockCommand.length), multiCommandFlag);
|
||||
byte[] header = encodeHeader(uniqueId, sequenceNumber, (short) (bolusCommand.length + interlockCommand.length), multiCommandFlag);
|
||||
|
||||
return ByteBuffer.allocate(bolusCommand.length + interlockCommand.length + header.length) //
|
||||
.put(header) //
|
||||
|
@ -76,7 +76,7 @@ public final class ProgramBasalCommand extends HeaderEnabledCommand {
|
|||
", remainingTenthPulsesInCurrentInsulinProgramElement=" + remainingTenthPulsesInCurrentInsulinProgramElement +
|
||||
", delayUntilNextTenthPulseInUsec=" + delayUntilNextTenthPulseInUsec +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -115,16 +115,16 @@ public final class ProgramBasalCommand extends HeaderEnabledCommand {
|
|||
|
||||
short[] pulsesPerSlot = ProgramBasalUtil.mapBasalProgramToPulsesPerSlot(basalProgram);
|
||||
CurrentSlot currentSlot = ProgramBasalUtil.calculateCurrentSlot(pulsesPerSlot, currentTime);
|
||||
short checksum = ProgramBasalUtil.createChecksum(pulsesPerSlot, currentSlot);
|
||||
List<LongInsulinProgramElement> longInsulinProgramElements = ProgramBasalUtil.mapPulsesPerSlotToLongInsulinProgramElements(pulsesPerSlot);
|
||||
List<ShortInsulinProgramElement> shortInsulinProgramElements = ProgramBasalUtil.mapPulsesPerSlotToShortInsulinProgramElements(pulsesPerSlot);
|
||||
short checksum = ProgramBasalUtil.createChecksum();
|
||||
CurrentLongInsulinProgramElement currentLongInsulinProgramElement = ProgramBasalUtil.calculateCurrentLongInsulinProgramElement(longInsulinProgramElements, currentTime);
|
||||
|
||||
ProgramInsulinCommand interlockCommand = new ProgramInsulinCommand(address, sequenceNumber, multiCommandFlag, nonce,
|
||||
ProgramInsulinCommand interlockCommand = new ProgramInsulinCommand(uniqueId, sequenceNumber, multiCommandFlag, nonce,
|
||||
shortInsulinProgramElements, currentSlot.getIndex(), checksum, (short) (currentSlot.getEighthSecondsRemaining() * 8),
|
||||
currentSlot.getPulsesRemaining(), ProgramInsulinCommand.DeliveryType.BASAL);
|
||||
|
||||
return new ProgramBasalCommand(interlockCommand, address, sequenceNumber, multiCommandFlag,
|
||||
return new ProgramBasalCommand(interlockCommand, uniqueId, sequenceNumber, multiCommandFlag,
|
||||
longInsulinProgramElements, programReminder, currentLongInsulinProgramElement.getIndex(),
|
||||
currentLongInsulinProgramElement.getRemainingTenthPulses(), currentLongInsulinProgramElement.getDelayUntilNextTenthPulseInUsec());
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ final class ProgramInsulinCommand extends NonceEnabledCommand {
|
|||
private final short remainingPulsesInCurrentSlot;
|
||||
private final DeliveryType deliveryType;
|
||||
|
||||
ProgramInsulinCommand(int address, short sequenceNumber, boolean multiCommandFlag, int nonce, List<ShortInsulinProgramElement> insulinProgramElements, byte currentSlot, short checksum, short remainingEighthSecondsInCurrentSlot, short remainingPulsesInCurrentSlot, DeliveryType deliveryType) {
|
||||
super(CommandType.PROGRAM_INSULIN, address, sequenceNumber, multiCommandFlag, nonce);
|
||||
ProgramInsulinCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, int nonce, List<ShortInsulinProgramElement> insulinProgramElements, byte currentSlot, short checksum, short remainingEighthSecondsInCurrentSlot, short remainingPulsesInCurrentSlot, DeliveryType deliveryType) {
|
||||
super(CommandType.PROGRAM_INSULIN, uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
this.insulinProgramElements = new ArrayList<>(insulinProgramElements);
|
||||
this.currentSlot = currentSlot;
|
||||
this.checksum = checksum;
|
||||
|
@ -79,7 +79,7 @@ final class ProgramInsulinCommand extends NonceEnabledCommand {
|
|||
", deliveryType=" + deliveryType +
|
||||
", nonce=" + nonce +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.HeaderEnabledCommandBuilder;
|
||||
|
||||
public final class SetUniqueIdCommand extends HeaderEnabledCommand {
|
||||
private static final int DEFAULT_ADDRESS = -1;
|
||||
private static final int DEFAULT_UNIQUE_ID = -1;
|
||||
private static final short LENGTH = 21;
|
||||
private static final byte BODY_LENGTH = 19;
|
||||
|
||||
|
@ -17,8 +17,8 @@ public final class SetUniqueIdCommand extends HeaderEnabledCommand {
|
|||
private final int podSequenceNumber;
|
||||
private final Date initializationTime;
|
||||
|
||||
SetUniqueIdCommand(int address, short sequenceNumber, boolean multiCommandFlag, int lotNumber, int podSequenceNumber, Date initializationTime) {
|
||||
super(CommandType.SET_UNIQUE_ID, address, sequenceNumber, multiCommandFlag);
|
||||
SetUniqueIdCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, int lotNumber, int podSequenceNumber, Date initializationTime) {
|
||||
super(CommandType.SET_UNIQUE_ID, uniqueId, sequenceNumber, multiCommandFlag);
|
||||
this.lotNumber = lotNumber;
|
||||
this.podSequenceNumber = podSequenceNumber;
|
||||
this.initializationTime = initializationTime;
|
||||
|
@ -26,10 +26,10 @@ public final class SetUniqueIdCommand extends HeaderEnabledCommand {
|
|||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(DEFAULT_ADDRESS, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(address) //
|
||||
.putInt(uniqueId) //
|
||||
.put((byte) 0x14) // FIXME ??
|
||||
.put((byte) 0x04) // FIXME ??
|
||||
.put(encodeInitializationTime(initializationTime)) //
|
||||
|
@ -57,7 +57,7 @@ public final class SetUniqueIdCommand extends HeaderEnabledCommand {
|
|||
", podSequenceNumber=" + podSequenceNumber +
|
||||
", initializationTime=" + initializationTime +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -93,7 +93,7 @@ public final class SetUniqueIdCommand extends HeaderEnabledCommand {
|
|||
if (initializationTime == null) {
|
||||
throw new IllegalArgumentException("initializationTime can not be null");
|
||||
}
|
||||
return new SetUniqueIdCommand(address, sequenceNumber, multiCommandFlag, lotNumber, podSequenceNumber, initializationTime);
|
||||
return new SetUniqueIdCommand(uniqueId, sequenceNumber, multiCommandFlag, lotNumber, podSequenceNumber, initializationTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ public final class SilenceAlertsCommand extends NonceEnabledCommand {
|
|||
|
||||
private final SilenceAlertCommandParameters parameters;
|
||||
|
||||
SilenceAlertsCommand(int address, short sequenceNumber, boolean multiCommandFlag, SilenceAlertCommandParameters parameters, int nonce) {
|
||||
super(CommandType.SILENCE_ALERTS, address, sequenceNumber, multiCommandFlag, nonce);
|
||||
SilenceAlertsCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, SilenceAlertCommandParameters parameters, int nonce) {
|
||||
super(CommandType.SILENCE_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(nonce) //
|
||||
|
@ -32,8 +32,9 @@ public final class SilenceAlertsCommand extends NonceEnabledCommand {
|
|||
@Override public String toString() {
|
||||
return "SilenceAlertsCommand{" +
|
||||
"parameters=" + parameters +
|
||||
", nonce=" + nonce +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -126,7 +127,7 @@ public final class SilenceAlertsCommand extends NonceEnabledCommand {
|
|||
}
|
||||
|
||||
@Override protected final SilenceAlertsCommand buildCommand() {
|
||||
return new SilenceAlertsCommand(address, sequenceNumber, multiCommandFlag, new SilenceAlertCommandParameters(silenceAutoOffAlert, silenceMultiCommandAlert, silenceExpirationImminentAlert, silenceUserSetExpirationAlert, silenceLowReservoirAlert, silenceSuspendInProgressAlert, silenceSuspendEndedAlert, silencePodExpirationAlert), nonce);
|
||||
return new SilenceAlertsCommand(uniqueId, sequenceNumber, multiCommandFlag, new SilenceAlertCommandParameters(silenceAutoOffAlert, silenceMultiCommandAlert, silenceExpirationImminentAlert, silenceUserSetExpirationAlert, silenceLowReservoirAlert, silenceSuspendInProgressAlert, silenceSuspendEndedAlert, silencePodExpirationAlert), nonce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,15 +16,15 @@ public final class StopDeliveryCommand extends NonceEnabledCommand {
|
|||
private final DeliveryType deliveryType;
|
||||
private final BeepType beepType;
|
||||
|
||||
StopDeliveryCommand(int address, short sequenceNumber, boolean multiCommandFlag, DeliveryType deliveryType, BeepType beepType, int nonce) {
|
||||
super(CommandType.STOP_DELIVERY, address, sequenceNumber, multiCommandFlag, nonce);
|
||||
StopDeliveryCommand(int uniqueId, short sequenceNumber, boolean multiCommandFlag, DeliveryType deliveryType, BeepType beepType, int nonce) {
|
||||
super(CommandType.STOP_DELIVERY, uniqueId, sequenceNumber, multiCommandFlag, nonce);
|
||||
this.deliveryType = deliveryType;
|
||||
this.beepType = beepType;
|
||||
}
|
||||
|
||||
@Override public byte[] getEncoded() {
|
||||
return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
|
||||
.put(encodeHeader(address, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //
|
||||
.put(commandType.getValue()) //
|
||||
.put(BODY_LENGTH) //
|
||||
.putInt(nonce) //
|
||||
|
@ -36,8 +36,9 @@ public final class StopDeliveryCommand extends NonceEnabledCommand {
|
|||
return "StopDeliveryCommand{" +
|
||||
"deliveryType=" + deliveryType +
|
||||
", beepType=" + beepType +
|
||||
", nonce=" + nonce +
|
||||
", commandType=" + commandType +
|
||||
", address=" + address +
|
||||
", uniqueId=" + uniqueId +
|
||||
", sequenceNumber=" + sequenceNumber +
|
||||
", multiCommandFlag=" + multiCommandFlag +
|
||||
'}';
|
||||
|
@ -89,7 +90,7 @@ public final class StopDeliveryCommand extends NonceEnabledCommand {
|
|||
if (beepType == null) {
|
||||
throw new IllegalArgumentException("beepType can not be null");
|
||||
}
|
||||
return new StopDeliveryCommand(address, sequenceNumber, multiCommandFlag, deliveryType, beepType, nonce);
|
||||
return new StopDeliveryCommand(uniqueId, sequenceNumber, multiCommandFlag, deliveryType, beepType, nonce);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ public abstract class HeaderEnabledCommand implements Command {
|
|||
protected static final short HEADER_LENGTH = 6;
|
||||
|
||||
protected final CommandType commandType;
|
||||
protected final int address;
|
||||
protected final int uniqueId;
|
||||
protected final short sequenceNumber;
|
||||
protected final boolean multiCommandFlag;
|
||||
|
||||
protected HeaderEnabledCommand(CommandType commandType, int address, short sequenceNumber, boolean multiCommandFlag) {
|
||||
protected HeaderEnabledCommand(CommandType commandType, int uniqueId, short sequenceNumber, boolean multiCommandFlag) {
|
||||
this.commandType = commandType;
|
||||
this.address = address;
|
||||
this.uniqueId = uniqueId;
|
||||
this.sequenceNumber = sequenceNumber;
|
||||
this.multiCommandFlag = multiCommandFlag;
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ public abstract class HeaderEnabledCommand implements Command {
|
|||
.array();
|
||||
}
|
||||
|
||||
protected static byte[] encodeHeader(int address, short sequenceNumber, short length, boolean multiCommandFlag) {
|
||||
protected static byte[] encodeHeader(int uniqueId, short sequenceNumber, short length, boolean multiCommandFlag) {
|
||||
return ByteBuffer.allocate(6) //
|
||||
.putInt(address) //
|
||||
.putInt(uniqueId) //
|
||||
.putShort((short) (((sequenceNumber & 0x0f) << 10) | length | ((multiCommandFlag ? 1 : 0) << 15))) //
|
||||
.array();
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
|
|||
public abstract class NonceEnabledCommand extends HeaderEnabledCommand {
|
||||
protected final int nonce;
|
||||
|
||||
protected NonceEnabledCommand(CommandType commandType, int address, short sequenceNumber, boolean multiCommandFlag, int nonce) {
|
||||
super(commandType, address, sequenceNumber, multiCommandFlag);
|
||||
protected NonceEnabledCommand(CommandType commandType, int uniqueId, short sequenceNumber, boolean multiCommandFlag, int nonce) {
|
||||
super(commandType, uniqueId, sequenceNumber, multiCommandFlag);
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command;
|
||||
|
||||
public abstract class HeaderEnabledCommandBuilder<T extends HeaderEnabledCommandBuilder<T, R>, R extends Command> implements CommandBuilder<R> {
|
||||
protected Integer address;
|
||||
protected Integer uniqueId;
|
||||
protected Short sequenceNumber;
|
||||
protected boolean multiCommandFlag = false;
|
||||
|
||||
public R build() {
|
||||
if (address == null) {
|
||||
throw new IllegalArgumentException("address can not be null");
|
||||
if (uniqueId == null) {
|
||||
throw new IllegalArgumentException("uniqueId can not be null");
|
||||
}
|
||||
if (sequenceNumber == null) {
|
||||
throw new IllegalArgumentException("sequenceNumber can not be null");
|
||||
|
@ -17,8 +17,8 @@ public abstract class HeaderEnabledCommandBuilder<T extends HeaderEnabledCommand
|
|||
return buildCommand();
|
||||
}
|
||||
|
||||
public final T setAddress(int address) {
|
||||
this.address = address;
|
||||
public final T setUniqueId(int uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ public class DeactivateCommandTest {
|
|||
@Test
|
||||
public void testEncoding() throws DecoderException {
|
||||
byte[] encoded = new DeactivateCommand.Builder() //
|
||||
.setAddress(37879809) //
|
||||
.setUniqueId(37879809) //
|
||||
.setSequenceNumber((short) 5) //
|
||||
.setNonce(1229869870) //
|
||||
.build() //
|
||||
|
|
|
@ -11,7 +11,7 @@ public class GetVersionCommandTest {
|
|||
public void testEncoding() throws DecoderException {
|
||||
byte[] encoded = new GetVersionCommand.Builder() //
|
||||
.setSequenceNumber((short) 0) //
|
||||
.setAddress(GetVersionCommand.DEFAULT_ADDRESS) //
|
||||
.setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) //
|
||||
.build() //
|
||||
.getEncoded();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class ProgramAlertsCommandTest {
|
|||
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4725, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 3) //
|
||||
.setMultiCommandFlag(true) //
|
||||
.setNonce(1229869870) //
|
||||
|
@ -40,7 +40,7 @@ public class ProgramAlertsCommandTest {
|
|||
configurations.add(new AlertConfiguration(AlertSlot.LOW_RESERVOIR, true, (short) 0, false, AlertTriggerType.RESERVOIR_VOLUME_TRIGGER, (short) 200, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 8) //
|
||||
.setNonce(1229869870) //
|
||||
.setAlertConfigurations(configurations) //
|
||||
|
@ -56,7 +56,7 @@ public class ProgramAlertsCommandTest {
|
|||
configurations.add(new AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4079, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX2));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 15) //
|
||||
.setNonce(1229869870) //
|
||||
.setAlertConfigurations(configurations) //
|
||||
|
@ -73,7 +73,7 @@ public class ProgramAlertsCommandTest {
|
|||
configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 55, false, AlertTriggerType.TIME_TRIGGER, (short) 5, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX5));
|
||||
|
||||
byte[] encoded = new ProgramAlertsCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 10) //
|
||||
.setMultiCommandFlag(false) //
|
||||
.setNonce(1229869870) //
|
||||
|
|
|
@ -12,7 +12,7 @@ public class SetUniqueIdCommandTest {
|
|||
@Test
|
||||
public void testEncoding() throws DecoderException {
|
||||
byte[] encoded = new SetUniqueIdCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 6) //
|
||||
.setLotNumber(135556289) //
|
||||
.setPodSequenceNumber(681767) //
|
||||
|
|
|
@ -10,7 +10,7 @@ public class SilenceAlertsCommandTest {
|
|||
@Test
|
||||
public void testSilenceLowReservoirAlert() throws DecoderException {
|
||||
byte[] encoded = new SilenceAlertsCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 1) //
|
||||
.setNonce(1229869870) //
|
||||
.setSilenceLowReservoirAlert(true) //
|
||||
|
|
|
@ -12,7 +12,7 @@ public class StopDeliveryCommandTest {
|
|||
@Test
|
||||
public void testStopTempBasal() throws DecoderException {
|
||||
byte[] encoded = new StopDeliveryCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 0) //
|
||||
.setNonce(1229869870) //
|
||||
.setDeliveryType(StopDeliveryCommand.DeliveryType.TEMP_BASAL) //
|
||||
|
@ -26,7 +26,7 @@ public class StopDeliveryCommandTest {
|
|||
@Test
|
||||
public void testSuspendDelivery() throws DecoderException {
|
||||
byte[] encoded = new StopDeliveryCommand.Builder() //
|
||||
.setAddress(37879811) //
|
||||
.setUniqueId(37879811) //
|
||||
.setSequenceNumber((short) 2) //
|
||||
.setNonce(1229869870) //
|
||||
.setDeliveryType(StopDeliveryCommand.DeliveryType.ALL) //
|
||||
|
|
Loading…
Reference in a new issue