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