Add AlarmStatusResponse (Status response page 2)

This commit is contained in:
Bart Sopers 2021-02-10 21:53:26 +01:00
parent e77f08cd23
commit d4ec8464ea
8 changed files with 525 additions and 38 deletions

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest package="info.nightscout.androidaps.plugins.pump.omnipod.dash">
package="info.nightscout.androidaps.plugins.pump.omnipod.dash">
</manifest> </manifest>

View file

@ -0,0 +1,174 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition;
public enum AlarmType {
NONE((byte) 0x00),
ALARM_PW_FLASH_ERASE((byte) 0x01),
ALARM_PW_FLASH_WRITE((byte) 0x02),
ALARM_BASAL_CKSUM((byte) 0x03),
ALARM_BASAL_PPULSE((byte) 0x04),
ALARM_BASAL_STEP((byte) 0x05),
ALARM_AUTO_WAKEUP_TIMEOUT((byte) 0x06),
ALARM_WIRE_OVERDRIVEN((byte) 0x07),
ALARM_BEEP_REP_INVALID_INDEX((byte) 0x08),
ALARM_INVALID_REP_PATTERN((byte) 0x09),
ALARM_TEMP_BASAL_STEP((byte) 0x0a),
ALARM_TEMP_BASAL_CKSUM((byte) 0x0b),
ALARM_BOLUS_OVERFLOW((byte) 0x0c),
ALARM_COP_RESET((byte) 0x0d),
ALARM_ILOP_RESET((byte) 0x0e),
ALARM_ILAD_RESET((byte) 0x0f),
ALARM_SAWCOP_RESET((byte) 0x10),
ALARM_BOLUS_STEP((byte) 0x11),
ALARM_LVD_RESET((byte) 0x12),
ALARM_INVALID_RF_MSG_LENGTH((byte) 0x13),
ALARM_OCCLUDED((byte) 0x14),
ALARM_BOLUSPROG_CHKSUM((byte) 0x15),
ALARM_BOLUS_LOG((byte) 0x16),
ALARM_CRITICAL_VAR((byte) 0x17),
ALARM_EMPTY_RESERVOIR((byte) 0x18),
ALARM_LOADERR((byte) 0x19),
ALARM_PSA_FAILURE((byte) 0x1a),
ALARM_TICKCNT_NOT_CLEARED((byte) 0x1b),
ALARM_PUMP_EXPIRED((byte) 0x1c),
ALARM_COMD_BIT_NOT_SET((byte) 0x1d),
ALARM_INVALID_COMD_SET((byte) 0x1e),
ALARM_ALERTS_ARRAY_CKSM((byte) 0x1f),
ALARM_UNIT_TEST((byte) 0x20),
ALARM_TICK_TIME_ERROR((byte) 0x21),
ALARM_CRITICAL_HAZARD((byte) 0x22),
ALARM_PIEZO_FREQ((byte) 0x23),
ALARM_TICKCNT_ERROR_RTC((byte) 0x24),
ALARM_TICK_FAILURE((byte) 0x25),
ALARM_INVALID((byte) 0x26),
ALARM_LUMP_ALERT_PROGRAM((byte) 0x27),
ALARM_INVALID_PASS_CODE((byte) 0x28),
ALARM_ALERT0((byte) 0x29),
ALARM_ALERT1((byte) 0x2a),
ALARM_ALERT2((byte) 0x2b),
ALARM_ALERT3((byte) 0x2c),
ALARM_ALERT4((byte) 0x2d),
ALARM_ALERT5((byte) 0x2e),
ALARM_ALERT6((byte) 0x2f),
ALARM_ALERT7((byte) 0x30),
ALARM_ILLEGAL_PUMP_STATE((byte) 0x31),
ALARM_COP_TEST_FAILURE((byte) 0x32),
ALARM_MCTF((byte) 0x33),
ALARM_ILLEGAL_RESET((byte) 0x34),
ALARM_VETO_NOT_SET((byte) 0x35),
ALARM_ILLEGAL_PIN_RESET((byte) 0x36),
ALARM_INVALID_BEEP_PATTERN((byte) 0x37),
ALARM_WIRE_STATE_MACHINE((byte) 0x38),
ALARM_VETO_TEST_DEFAULT((byte) 0x39),
ALARM_ALERT_INVALID_INDEX((byte) 0x3a),
ALARM_SAWCOP_TEST_FAIL((byte) 0x3b),
ALARM_MCUCOP_TEST_FAIL((byte) 0x3c),
ALARM_STEP_SENSOR_SHORTED((byte) 0x3d),
ALARM_FLASH_FAILURE((byte) 0x3e),
ALARM_SPARE63((byte) 0x3f),
ALARM_SS_OPEN_CNT_EXCEEDED((byte) 0x40),
ALARM_SS_EXCESSIVE_SUMMED((byte) 0x41),
ALARM_SS_MIN_PULSE_TRANSITION((byte) 0x42),
ALARM_SS_DEFAULT((byte) 0x43),
ALARM_OPEN_WIRE1((byte) 0x44),
ALARM_OPEN_WIRE2((byte) 0x45),
ALARM_LOADERR_FAILURE((byte) 0x46),
ALARM_SAW_VETO_FAILURE((byte) 0x47),
ALARM_BAD_RFM_CLOCK((byte) 0x48),
ALARM_BAD_TICK_HIGH((byte) 0x49),
ALARM_BAD_TICK_PERIOD((byte) 0x4a),
ALARM_BAD_TRIM_VALUE((byte) 0x4b),
ALARM_BAD_BUS_CLOCK((byte) 0x4c),
ALARM_BAD_CAL_MODE((byte) 0x4d),
ALARM_SAW_TRIM_ERROR((byte) 0x4e),
ALARM_RFM_CRYSTAL_ERROR((byte) 0x4f),
ALARM_CALST_TIMEOUT((byte) 0x50),
ALARM_TICKCNT_ERROR((byte) 0x51),
ALARM_BAD_RFM_XTAL_START((byte) 0x52),
ALARM_BAD_RX_SENSENSITIVITY((byte) 0x53),
ALARM_BAD_TX_PKT_SIZE((byte) 0x54),
ALARM_TICK_LOW_PHASE_EXCEEDED((byte) 0x55),
ALARM_TICK_HIGH_PHASE_EXCEEDED((byte) 0x56),
ALARM_OCCL_CRITVAR_FAIL((byte) 0x57),
ALARM_OCCL_PARAM((byte) 0x58),
ALARM_PROG_OCCL_FAIL((byte) 0x59),
ALARM_PW_TO_HIGH_FOR_OCCL_DET((byte) 0x5a),
ALARM_OCCL_CSUM((byte) 0x5b),
ALARM_PRIME_OPEN_CNT_TO_LOW((byte) 0x5c),
ALARM_BAD_RF_CDTHR((byte) 0x5d),
ALARM_FLASH_NOT_SECURE((byte) 0x5e),
ALARM_WIRE_TEST_OPEN_GROUND((byte) 0x5f),
ALARM_OCCL_STARTUP1((byte) 0x60),
ALARM_OCCL_STARTUP2((byte) 0x61),
ALARM_OCCL_EXCESS_TIMEOUTS1((byte) 0x62),
ALARM_SPARE99((byte) 0x63),
ALARM_SPARE100((byte) 0x64),
ALARM_SPARE101((byte) 0x65),
ALARM_OCCL_EXCESS_TIMEOUTS2((byte) 0x66),
ALARM_OCCL_EXCESS_TIMEOUTS3((byte) 0x67),
ALARM_OCCL_NOISY_PULSE_WIDTHS((byte) 0x68),
ALARM_OCCL_AT_BOLUS_END((byte) 0x69),
ALARM_OCCL_ABOVE_THRESHOLD((byte) 0x6a),
ALARM_BASAL_UNDERINFUSION((byte) 0x80),
ALARM_BASAL_OVERINFUSION((byte) 0x81),
ALARM_TEMP_UNDERINFUSION((byte) 0x82),
ALARM_TEMP_OVERINFUSION((byte) 0x83),
ALARM_BOLUS_UNDERINFUSION((byte) 0x84),
ALARM_BOLUS_OVERINFUSION((byte) 0x85),
ALARM_BASAL_OVERINFUSION_PULSE((byte) 0x86),
ALARM_TEMP_OVERINFUSION_PULSE((byte) 0x87),
ALARM_BOLUS_OVERINFUSION_PULSE((byte) 0x88),
ALARM_IMMBOLUS_UNDERINFUSION_PULSE((byte) 0x89),
ALARM_EXTBOLUS_OVERINFUSION_PULSE((byte) 0x8a),
ALARM_PROGRAM_CSUM((byte) 0x8b),
ALARM_UNUSED_140((byte) 0x8c),
ALARM_UNRECOGNIZED_PULSE((byte) 0x8d),
ALARM_SYNC_WITHOUT_TEMP_ACTIVE((byte) 0x8e),
ALARM_INTERLOCK_LOAD((byte) 0x8f),
ALARM_ILLEGAL_CHAN_PARAM((byte) 0x90),
ALARM_BASAL_PULSE_CHAN_INACTIVE((byte) 0x91),
ALARM_TEMP_PULSE_CHAN_INACTIVE((byte) 0x92),
ALARM_BOLUS_PULSE_CHAN_INACTIVE((byte) 0x93),
ALARM_INT_SEMAPHORE_NOT_SET((byte) 0x94),
ALARM_ILLEGAL_INTERLOCK_CHAN((byte) 0x95),
ALARM_TERMINATE_BOLUS((byte) 0x96),
ALARM_OPEN_TRANSITIONS_COUNT((byte) 0x97),
ALARM_BLE_TO((byte) 0xa0),
ALARM_BLE_INITIATED((byte) 0xa1),
ALARM_BLE_UNK_ALARM((byte) 0xa2),
ALARM_UNUSED_163((byte) 0xa3),
ALARM_UNUSED_164((byte) 0xa4),
ALARM_UNUSED_165((byte) 0xa5),
ALARM_BLE_IAAS((byte) 0xa6),
ALARM_UNUSED_167((byte) 0xa7),
ALARM_CRC_FAILURE((byte) 0xa8),
ALARM_BLE_WD_PING_TIMEOUT((byte) 0xa9),
ALARM_BLE_EXCESSIVE_RESETS((byte) 0xaa),
ALARM_BLE_NAK_ERROR((byte) 0xab),
ALARM_BLE_REQ_HIGH_TIMEOUT((byte) 0xac),
ALARM_BLE_UNKNOWN_RESP((byte) 0xad),
ALARM_BLE_UNUSED_174((byte) 0xae),
ALARM_BLE_REQ_STUCK_HIGH((byte) 0xaf),
ALARM_BLE_STATE_MACHINE_1((byte) 0xb1),
ALARM_BLE_STATE_MACHINE_2((byte) 0xb2),
ALARM_BLE_UNUSED_179((byte) 0xb3),
ALARM_BLE_ARB_LOST((byte) 0xb4),
ALARM_BLE_ER48_DUAL_NACK((byte) 0xc0),
ALARM_BLE_QN_EXCEED_MAX_RETRY((byte) 0xc1),
ALARM_BLE_QN_CRIT_VAR_FAIL((byte) 0xc2),
UNKNOWN((byte) 0xff);
private byte value;
AlarmType(byte value) {
this.value = value;
}
public static AlarmType byValue(byte value) {
for (AlarmType type : values()) {
if (type.value == value) {
return type;
}
}
return UNKNOWN;
}
}

View file

@ -0,0 +1,14 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
public class AdditionalStatusResponseBase extends ResponseBase {
final ResponseType.AdditionalStatusResponseType statusResponseType;
AdditionalStatusResponseBase(ResponseType.AdditionalStatusResponseType statusResponseType, byte[] encoded) {
super(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded);
this.statusResponseType = statusResponseType;
}
public ResponseType.AdditionalStatusResponseType getStatusResponseType() {
return statusResponseType;
}
}

View file

@ -0,0 +1,240 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import java.nio.ByteBuffer;
import java.util.Arrays;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
public class AlarmStatusResponse extends AdditionalStatusResponseBase {
private final byte messageType;
private final short messageLength;
private final byte additionalStatusResponseType;
private final PodStatus podStatus;
private final DeliveryStatus deliveryStatus;
private final short bolusPulsesRemaining;
private final short sequenceNumberOfLastProgrammingCommand;
private final short totalPulsesDelivered;
private final AlarmType alarmType;
private final short alarmTime;
private final short reservoirPulsesRemaining;
private final short minutesSinceActivation;
private final boolean alert0Active;
private final boolean alert1Active;
private final boolean alert2Active;
private final boolean alert3Active;
private final boolean alert4Active;
private final boolean alert5Active;
private final boolean alert6Active;
private final boolean alert7Active;
private final boolean occlusionAlarm;
private final boolean pulseInfoInvalid;
private final PodStatus podStatusWhenAlarmOccurred;
private final boolean immediateBolusWhenAlarmOccurred;
private final byte occlusionType;
private final boolean occurredWhenFetchingImmediateBolusActiveInformation;
private final short rssi;
private final short receiverLowerGain;
private final PodStatus podStatusWhenAlarmOccurred2;
private final short returnAddressOfPodAlarmHandlerCaller;
public AlarmStatusResponse(byte[] encoded) {
super(ResponseType.AdditionalStatusResponseType.ALARM_STATUS, encoded);
messageType = encoded[0];
messageLength = (short) (encoded[1] & 0xff);
additionalStatusResponseType = encoded[2];
podStatus = PodStatus.byValue((byte) (encoded[3] & 0x0f));
deliveryStatus = DeliveryStatus.byValue((byte) (encoded[4] & 0x0f));
bolusPulsesRemaining = (short) (ByteBuffer.wrap(new byte[]{encoded[5], encoded[6]}).getShort() & 2047);
sequenceNumberOfLastProgrammingCommand = (short) (encoded[7] & 0x0f);
totalPulsesDelivered = ByteBuffer.wrap(new byte[]{encoded[8], encoded[9]}).getShort();
alarmType = AlarmType.byValue(encoded[10]);
alarmTime = ByteBuffer.wrap(new byte[]{encoded[11], encoded[12]}).getShort();
reservoirPulsesRemaining = ByteBuffer.wrap(new byte[]{encoded[13], encoded[14]}).getShort();
minutesSinceActivation = ByteBuffer.wrap(new byte[]{encoded[15], encoded[16]}).getShort();
byte activeAlerts = encoded[17];
alert0Active = (activeAlerts & 1) == 1;
alert1Active = ((activeAlerts >>> 1) & 1) == 1;
alert2Active = ((activeAlerts >>> 2) & 1) == 1;
alert3Active = ((activeAlerts >>> 3) & 1) == 1;
alert4Active = ((activeAlerts >>> 4) & 1) == 1;
alert5Active = ((activeAlerts >>> 5) & 1) == 1;
alert6Active = ((activeAlerts >>> 6) & 1) == 1;
alert7Active = ((activeAlerts >>> 7) & 1) == 1;
byte alarmFlags = encoded[18];
occlusionAlarm = (alarmFlags & 1) == 1;
pulseInfoInvalid = ((alarmFlags >> 1) & 1) == 1;
byte byte19 = encoded[19];
byte byte20 = encoded[20];
podStatusWhenAlarmOccurred = PodStatus.byValue((byte) (byte19 & 0x0f));
immediateBolusWhenAlarmOccurred = ((byte19 >> 4) & 1) == 1;
occlusionType = (byte) ((byte19 >> 5) & 3);
occurredWhenFetchingImmediateBolusActiveInformation = ((byte19 >> 7) & 1) == 1;
rssi = (short) (byte20 & 0x3f);
receiverLowerGain = (short) ((byte20 >> 6) & 0x03);
podStatusWhenAlarmOccurred2 = PodStatus.byValue((byte) (encoded[21] & 0x0f));
returnAddressOfPodAlarmHandlerCaller = ByteBuffer.wrap(new byte[]{encoded[22], encoded[23]}).getShort();
}
public byte getMessageType() {
return messageType;
}
public short getMessageLength() {
return messageLength;
}
public byte getAdditionalStatusResponseType() {
return additionalStatusResponseType;
}
public PodStatus getPodStatus() {
return podStatus;
}
public DeliveryStatus getDeliveryStatus() {
return deliveryStatus;
}
public short getBolusPulsesRemaining() {
return bolusPulsesRemaining;
}
public short getSequenceNumberOfLastProgrammingCommand() {
return sequenceNumberOfLastProgrammingCommand;
}
public short getTotalPulsesDelivered() {
return totalPulsesDelivered;
}
public AlarmType getAlarmType() {
return alarmType;
}
public short getAlarmTime() {
return alarmTime;
}
public short getReservoirPulsesRemaining() {
return reservoirPulsesRemaining;
}
public short getMinutesSinceActivation() {
return minutesSinceActivation;
}
public boolean isAlert0Active() {
return alert0Active;
}
public boolean isAlert1Active() {
return alert1Active;
}
public boolean isAlert2Active() {
return alert2Active;
}
public boolean isAlert3Active() {
return alert3Active;
}
public boolean isAlert4Active() {
return alert4Active;
}
public boolean isAlert5Active() {
return alert5Active;
}
public boolean isAlert6Active() {
return alert6Active;
}
public boolean isAlert7Active() {
return alert7Active;
}
public boolean isOcclusionAlarm() {
return occlusionAlarm;
}
public boolean isPulseInfoInvalid() {
return pulseInfoInvalid;
}
public PodStatus getPodStatusWhenAlarmOccurred() {
return podStatusWhenAlarmOccurred;
}
public boolean isImmediateBolusWhenAlarmOccurred() {
return immediateBolusWhenAlarmOccurred;
}
public byte getOcclusionType() {
return occlusionType;
}
public boolean isOccurredWhenFetchingImmediateBolusActiveInformation() {
return occurredWhenFetchingImmediateBolusActiveInformation;
}
public short getRssi() {
return rssi;
}
public short getReceiverLowerGain() {
return receiverLowerGain;
}
public PodStatus getPodStatusWhenAlarmOccurred2() {
return podStatusWhenAlarmOccurred2;
}
public short getReturnAddressOfPodAlarmHandlerCaller() {
return returnAddressOfPodAlarmHandlerCaller;
}
@Override public String toString() {
return "AlarmStatusResponse{" +
"messageType=" + messageType +
", messageLength=" + messageLength +
", additionalStatusResponseType=" + additionalStatusResponseType +
", podStatus=" + podStatus +
", deliveryStatus=" + deliveryStatus +
", bolusPulsesRemaining=" + bolusPulsesRemaining +
", sequenceNumberOfLastProgrammingCommand=" + sequenceNumberOfLastProgrammingCommand +
", totalPulsesDelivered=" + totalPulsesDelivered +
", alarmType=" + alarmType +
", alarmTime=" + alarmTime +
", reservoirPulsesRemaining=" + reservoirPulsesRemaining +
", minutesSinceActivation=" + minutesSinceActivation +
", alert0Active=" + alert0Active +
", alert1Active=" + alert1Active +
", alert2Active=" + alert2Active +
", alert3Active=" + alert3Active +
", alert4Active=" + alert4Active +
", alert5Active=" + alert5Active +
", alert6Active=" + alert6Active +
", alert7Active=" + alert7Active +
", occlusionAlarm=" + occlusionAlarm +
", pulseInfoInvalid=" + pulseInfoInvalid +
", podStatusWhenAlarmOccurred=" + podStatusWhenAlarmOccurred +
", immediateBolusWhenAlarmOccurred=" + immediateBolusWhenAlarmOccurred +
", occlusionType=" + occlusionType +
", occurredWhenFetchingImmediateBolusActiveInformation=" + occurredWhenFetchingImmediateBolusActiveInformation +
", rssi=" + rssi +
", receiverLowerGain=" + receiverLowerGain +
", podStatusWhenAlarmOccurred2=" + podStatusWhenAlarmOccurred2 +
", returnAddressOfPodAlarmHandlerCaller=" + returnAddressOfPodAlarmHandlerCaller +
", statusResponseType=" + statusResponseType +
", responseType=" + responseType +
", encoded=" + Arrays.toString(encoded) +
'}';
}
}

View file

@ -26,25 +26,25 @@ public class DefaultStatusResponse extends ResponseBase {
public DefaultStatusResponse(byte[] encoded) { public DefaultStatusResponse(byte[] encoded) {
super(ResponseType.DEFAULT_STATUS_RESPONSE, encoded); super(ResponseType.DEFAULT_STATUS_RESPONSE, encoded);
this.messageType = encoded[0]; messageType = encoded[0];
this.deliveryStatus = DeliveryStatus.byValue((byte) ((encoded[1] >> 4) & 0x0f)); deliveryStatus = DeliveryStatus.byValue((byte) ((encoded[1] >> 4) & 0x0f));
this.podStatus = PodStatus.byValue((byte) (encoded[1] & 0x0f)); podStatus = PodStatus.byValue((byte) (encoded[1] & 0x0f));
this.totalPulsesDelivered = (short) (((encoded[2] & 0x0f) << 12) | ((encoded[3] & 0xff) << 1) | ((encoded[4] & 0xff) >>> 7)); totalPulsesDelivered = (short) (((encoded[2] & 0x0f) << 12) | ((encoded[3] & 0xff) << 1) | ((encoded[4] & 0xff) >>> 7));
this.sequenceNumberOfLastProgrammingCommand = (byte) ((encoded[4] >>> 3) & 0x0f); sequenceNumberOfLastProgrammingCommand = (byte) ((encoded[4] >>> 3) & 0x0f);
this.bolusPulsesRemaining = (short) (((encoded[4] & 0x07) << 10) | (encoded[5] & 0xff)); bolusPulsesRemaining = (short) ((((encoded[4] & 0x07) << 10) | (encoded[5] & 0xff)) & 2047);
short activeAlerts = (short) (((encoded[6] & 0xff) << 1) | (encoded[7] >>> 7)); short activeAlerts = (short) (((encoded[6] & 0xff) << 1) | (encoded[7] >>> 7));
this.occlusionAlertActive = (activeAlerts & 1) == 1; occlusionAlertActive = (activeAlerts & 1) == 1;
this.alert1Active = ((activeAlerts >> 1) & 1) == 1; alert1Active = ((activeAlerts >> 1) & 1) == 1;
this.alert2Active = ((activeAlerts >> 2) & 1) == 1; alert2Active = ((activeAlerts >> 2) & 1) == 1;
this.alert3Active = ((activeAlerts >> 3) & 1) == 1; alert3Active = ((activeAlerts >> 3) & 1) == 1;
this.alert4Active = ((activeAlerts >> 4) & 1) == 1; alert4Active = ((activeAlerts >> 4) & 1) == 1;
this.alert5Active = ((activeAlerts >> 5) & 1) == 1; alert5Active = ((activeAlerts >> 5) & 1) == 1;
this.alert6Active = ((activeAlerts >> 6) & 1) == 1; alert6Active = ((activeAlerts >> 6) & 1) == 1;
this.alert7Active = ((activeAlerts >> 7) & 1) == 1; alert7Active = ((activeAlerts >> 7) & 1) == 1;
this.minutesSinceActivation = (short) (((encoded[7] & 0x7f) << 6) | (((encoded[8] & 0xff) >>> 2) & 0x3f)); minutesSinceActivation = (short) (((encoded[7] & 0x7f) << 6) | (((encoded[8] & 0xff) >>> 2) & 0x3f));
this.reservoirPulsesRemaining = (short) (((encoded[8] << 8) | encoded[9]) & 0x3ff); reservoirPulsesRemaining = (short) (((encoded[8] << 8) | encoded[9]) & 0x3ff);
} }
public byte getMessageType() { public byte getMessageType() {

View file

@ -28,7 +28,7 @@ public enum ResponseType {
enum AdditionalStatusResponseType { enum AdditionalStatusResponseType {
STATUS_RESPONSE_PAGE_1((byte) 0x01), STATUS_RESPONSE_PAGE_1((byte) 0x01),
STATUS_RESPONSE_PAGE_2((byte) 0x02), ALARM_STATUS((byte) 0x02),
STATUS_RESPONSE_PAGE_3((byte) 0x03), STATUS_RESPONSE_PAGE_3((byte) 0x03),
STATUS_RESPONSE_PAGE_5((byte) 0x05), STATUS_RESPONSE_PAGE_5((byte) 0x05),
STATUS_RESPONSE_PAGE_6((byte) 0x06), STATUS_RESPONSE_PAGE_6((byte) 0x06),
@ -51,6 +51,10 @@ public enum ResponseType {
} }
return UNKNOWN; return UNKNOWN;
} }
public byte getValue() {
return value;
}
} }
enum ActivationResponseType { enum ActivationResponseType {

View file

@ -29,25 +29,25 @@ public final class SetUniqueIdResponse extends ActivationResponseBase {
public SetUniqueIdResponse(byte[] encoded) { public SetUniqueIdResponse(byte[] encoded) {
super(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, encoded); super(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, encoded);
this.messageType = encoded[0]; messageType = encoded[0];
this.messageLength = (short) (encoded[1] & 0xff); messageLength = (short) (encoded[1] & 0xff);
this.pulseVolumeInTenThousandthMicroLiter = ByteBuffer.wrap(new byte[]{encoded[2], encoded[3]}).getShort(); pulseVolumeInTenThousandthMicroLiter = ByteBuffer.wrap(new byte[]{encoded[2], encoded[3]}).getShort();
this.pumpRate = (short) (encoded[4] & 0xff); pumpRate = (short) (encoded[4] & 0xff);
this.primePumpRate = (short) (encoded[5] & 0xff); primePumpRate = (short) (encoded[5] & 0xff);
this.numberOfEngagingClutchDrivePulses = (short) (encoded[6] & 0xff); numberOfEngagingClutchDrivePulses = (short) (encoded[6] & 0xff);
this.numberOfPrimePulses = (short) (encoded[7] & 0xff); numberOfPrimePulses = (short) (encoded[7] & 0xff);
this.podExpirationTimeInHours = (short) (encoded[8] & 0xff); podExpirationTimeInHours = (short) (encoded[8] & 0xff);
this.firmwareVersionMajor = (short) (encoded[9] & 0xff); firmwareVersionMajor = (short) (encoded[9] & 0xff);
this.firmwareVersionMinor = (short) (encoded[10] & 0xff); firmwareVersionMinor = (short) (encoded[10] & 0xff);
this.firmwareVersionInterim = (short) (encoded[11] & 0xff); firmwareVersionInterim = (short) (encoded[11] & 0xff);
this.bleVersionMajor = (short) (encoded[12] & 0xff); bleVersionMajor = (short) (encoded[12] & 0xff);
this.bleVersionMinor = (short) (encoded[13] & 0xff); bleVersionMinor = (short) (encoded[13] & 0xff);
this.bleVersionInterim = (short) (encoded[14] & 0xff); bleVersionInterim = (short) (encoded[14] & 0xff);
this.productId = (short) (encoded[15] & 0xff); productId = (short) (encoded[15] & 0xff);
this.podStatus = PodStatus.byValue(encoded[16]); podStatus = PodStatus.byValue(encoded[16]);
this.lotNumber = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[17], encoded[18], encoded[19], encoded[20]}).getLong(); lotNumber = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[17], encoded[18], encoded[19], encoded[20]}).getLong();
this.podSequenceNumber = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[21], encoded[22], encoded[23], encoded[24]}).getLong(); podSequenceNumber = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[21], encoded[22], encoded[23], encoded[24]}).getLong();
this.uniqueIdReceivedInCommand = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[25], encoded[26], encoded[27], encoded[28]}).getLong(); uniqueIdReceivedInCommand = ByteBuffer.wrap(new byte[]{0, 0, 0, 0, encoded[25], encoded[26], encoded[27], encoded[28]}).getLong();
} }
public byte getMessageType() { public byte getMessageType() {

View file

@ -0,0 +1,56 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
public class AlarmStatusResponseTest {
@Test
public void testValidResponse() throws DecoderException {
byte[] encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A");
AlarmStatusResponse response = new AlarmStatusResponse(encoded);
assertArrayEquals(encoded, response.getEncoded());
assertNotSame(encoded, response.getEncoded());
assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.getResponseType());
assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.getValue(), response.getMessageType());
assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS, response.getStatusResponseType());
assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS.getValue(), response.getAdditionalStatusResponseType());
assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus());
assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus());
assertEquals((short) 0, response.getBolusPulsesRemaining());
assertEquals((short) 5, response.getSequenceNumberOfLastProgrammingCommand());
assertEquals((short) 445, response.getTotalPulsesDelivered());
assertEquals(AlarmType.NONE, response.getAlarmType());
assertEquals((short) 0, response.getAlarmTime());
assertEquals((short) 1023, response.getReservoirPulsesRemaining());
assertEquals((short) 405, response.getMinutesSinceActivation());
assertFalse(response.isAlert0Active());
assertFalse(response.isAlert1Active());
assertFalse(response.isAlert2Active());
assertFalse(response.isAlert3Active());
assertFalse(response.isAlert4Active());
assertFalse(response.isAlert5Active());
assertFalse(response.isAlert6Active());
assertFalse(response.isAlert7Active());
assertFalse(response.isOcclusionAlarm());
assertFalse(response.isPulseInfoInvalid());
assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred());
assertFalse(response.isImmediateBolusWhenAlarmOccurred());
assertEquals((byte) 0x00, response.getOcclusionType());
assertFalse(response.isOccurredWhenFetchingImmediateBolusActiveInformation());
assertEquals(0, response.getRssi());
assertEquals(0, response.getReceiverLowerGain());
assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred2());
assertEquals((short) 26378, response.getReturnAddressOfPodAlarmHandlerCaller());
}
}