Apply new understandings of beep types
This commit is contained in:
parent
5ac0df4b4b
commit
d14789cf02
|
@ -4,11 +4,11 @@ import org.joda.time.Duration;
|
|||
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepConfigType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType;
|
||||
|
||||
public class BeepConfigCommand extends MessageBlock {
|
||||
private final BeepType beepType;
|
||||
private final BeepConfigType beepType;
|
||||
private final boolean basalCompletionBeep;
|
||||
private final Duration basalIntervalBeep;
|
||||
private final boolean tempBasalCompletionBeep;
|
||||
|
@ -16,7 +16,7 @@ public class BeepConfigCommand extends MessageBlock {
|
|||
private final boolean bolusCompletionBeep;
|
||||
private final Duration bolusIntervalBeep;
|
||||
|
||||
public BeepConfigCommand(BeepType beepType, boolean basalCompletionBeep, Duration basalIntervalBeep,
|
||||
public BeepConfigCommand(BeepConfigType beepType, boolean basalCompletionBeep, Duration basalIntervalBeep,
|
||||
boolean tempBasalCompletionBeep, Duration tempBasalIntervalBeep,
|
||||
boolean bolusCompletionBeep, Duration bolusIntervalBeep) {
|
||||
this.beepType = beepType;
|
||||
|
@ -30,7 +30,7 @@ public class BeepConfigCommand extends MessageBlock {
|
|||
encode();
|
||||
}
|
||||
|
||||
public BeepConfigCommand(BeepType beepType) {
|
||||
public BeepConfigCommand(BeepConfigType beepType) {
|
||||
this(beepType, false, Duration.ZERO, false, Duration.ZERO, false, Duration.ZERO);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||
|
||||
|
||||
// BeepConfigType is used only for the $1E Beep Config Command.
|
||||
public enum BeepConfigType {
|
||||
// 0x0 always returns an error response for Beep Config (use 0xF for no beep)
|
||||
BEEP_BEEP_BEEP_BEEP((byte) 0x01),
|
||||
BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP((byte) 0x02),
|
||||
BIP_BIP((byte) 0x03),
|
||||
BEEP((byte) 0x04),
|
||||
BEEP_BEEP_BEEP((byte) 0x05),
|
||||
BEEEEEEP((byte) 0x06),
|
||||
BIP_BIP_BIP_BIP_BIP_BIP((byte) 0x07),
|
||||
BEEEP_BEEEP((byte) 0x08),
|
||||
// 0x9 and 0xA always return an error response for Beep Config
|
||||
BEEP_BEEP((byte) 0xB),
|
||||
BEEEP((byte) 0xC),
|
||||
BIP_BEEEEEP((byte) 0xD),
|
||||
FIVE_SECONDS_BEEP((byte) 0xE), // can only be used if Pod is currently suspended
|
||||
NO_BEEP((byte) 0xF);
|
||||
|
||||
private byte value;
|
||||
|
||||
BeepConfigType(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static BeepConfigType fromByte(byte value) {
|
||||
for (BeepConfigType type : values()) {
|
||||
if (type.value == value) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown BeepConfigType: " + value);
|
||||
}
|
||||
|
||||
public byte getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||
|
||||
// BeepType is used for the $19 Configure Alerts and $1F Cancel Commands
|
||||
public enum BeepType {
|
||||
NO_BEEP((byte) 0x00),
|
||||
BEEP_BEEP_BEEP_BEEP((byte) 0x01),
|
||||
|
@ -9,12 +10,7 @@ public enum BeepType {
|
|||
BEEP_BEEP_BEEP((byte) 0x05),
|
||||
BEEEEEEP((byte) 0x06),
|
||||
BIP_BIP_BIP_BIP_BIP_BIP((byte) 0x07),
|
||||
BEEEP_BEEEP((byte) 0x08),
|
||||
BEEP_BEEP((byte) 0xB),
|
||||
BEEEP((byte) 0xC),
|
||||
BIP_BEEEEEP((byte) 0xD),
|
||||
FIVE_SECONDS_BEEP((byte) 0xE),
|
||||
BEEP_CONFIG_NO_BEEP((byte) 0xF);
|
||||
BEEEP_BEEEP((byte) 0x08);
|
||||
|
||||
private byte value;
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@ import org.mockito.ArgumentCaptor;
|
|||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSetupState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -47,7 +47,7 @@ public class PairServiceTest {
|
|||
VersionResponse versionResponse = new PairService().executeAssignAddressCommand(communicationService, setupState);
|
||||
|
||||
// verify
|
||||
verify(communicationService).exchangeMessages(eq(VersionResponse.class), eq(setupState), messageCaptor.capture(), eq(Constants.DEFAULT_ADDRESS), eq(0x1f173217));
|
||||
verify(communicationService).exchangeMessages(eq(VersionResponse.class), eq(setupState), messageCaptor.capture(), eq(OmnipodConst.DEFAULT_ADDRESS), eq(0x1f173217));
|
||||
verifyNoMoreInteractions(communicationService);
|
||||
verifyZeroInteractions(response);
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import org.joda.time.Duration;
|
|||
import org.junit.Test;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepConfigType;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class BeepConfigCommandTest {
|
||||
@Test
|
||||
public void testConfidenceReminders() {
|
||||
BeepConfigCommand beepConfigCommand = new BeepConfigCommand(BeepType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, true,
|
||||
BeepConfigCommand beepConfigCommand = new BeepConfigCommand(BeepConfigType.BIP_BEEP_BIP_BEEP_BIP_BEEP_BIP_BEEP, true,
|
||||
Duration.ZERO, true, Duration.ZERO,
|
||||
true, Duration.ZERO);
|
||||
assertArrayEquals(ByteUtil.fromHexString("1e0402404040"), beepConfigCommand.getRawData());
|
||||
|
@ -19,7 +19,7 @@ public class BeepConfigCommandTest {
|
|||
|
||||
@Test
|
||||
public void testProgramReminders() {
|
||||
BeepConfigCommand beepConfigCommand = new BeepConfigCommand(BeepType.BEEP_CONFIG_NO_BEEP, true,
|
||||
BeepConfigCommand beepConfigCommand = new BeepConfigCommand(BeepConfigType.NO_BEEP, true,
|
||||
Duration.ZERO, false, Duration.standardMinutes(60),
|
||||
false, Duration.standardMinutes(60));
|
||||
assertArrayEquals(ByteUtil.fromHexString("1e040f403c3c"), beepConfigCommand.getRawData());
|
||||
|
|
|
@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response;
|
|||
import org.joda.time.Duration;
|
||||
import org.junit.Test;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -58,9 +58,9 @@ public class StatusResponseTest {
|
|||
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||
|
||||
assertEquals(Duration.standardMinutes(8191).getMillis(), statusResponse.getTimeActive().getMillis());
|
||||
assertEquals(Constants.POD_PULSE_SIZE * 1023, statusResponse.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(OmnipodConst.POD_PULSE_SIZE * 1023, statusResponse.getInsulinNotDelivered(), 0.000001);
|
||||
assertNull("Reservoir level should be null", statusResponse.getReservoirLevel());
|
||||
assertEquals(Constants.POD_PULSE_SIZE * 8191, statusResponse.getInsulin(), 0.0000001);
|
||||
assertEquals(OmnipodConst.POD_PULSE_SIZE * 8191, statusResponse.getInsulin(), 0.0000001);
|
||||
assertEquals(15, statusResponse.getPodMessageCounter());
|
||||
assertEquals(8, statusResponse.getAlerts().getAlertSlots().size());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue