Add NakResponse (untested)
This commit is contained in:
parent
43c3b42912
commit
93e4e924fa
|
@ -0,0 +1,49 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition;
|
||||
|
||||
public enum NakErrorType {
|
||||
FLASH_WRITE((byte) 0x01),
|
||||
FLASH_ERASE((byte) 0x02),
|
||||
FLASH_OPERATION((byte) 0x03),
|
||||
FLASH_ADDR((byte) 0x04),
|
||||
POD_STATE((byte) 0x05),
|
||||
CRITICAL_VARIABLE((byte) 0x06),
|
||||
ILLEGAL_PARAM((byte) 0x07),
|
||||
BOLUS_CRITICAL_VAR((byte) 0x08),
|
||||
INT_ILLEGAL_PARAM((byte) 0x09),
|
||||
ILLEGAL_CHECKSUM((byte) 0x0a),
|
||||
INVALID_MSG_LEN((byte) 0x0b),
|
||||
PUMP_STATE((byte) 0x0c),
|
||||
ILLEGAL_COMMAND((byte) 0x0d),
|
||||
ILLEGAL_FILL_STATE((byte) 0x0e),
|
||||
MAX_READWRITE_SIZE((byte) 0x0f),
|
||||
ILLEGAL_READ_ADDRESS((byte) 0x10),
|
||||
ILLEGAL_READ_MEM_TYPE((byte) 0x11),
|
||||
INIT_POD((byte) 0x12),
|
||||
ILLEGAL_CMD_STATE((byte) 0x13),
|
||||
ILLEGAL_SECURITY_CODE((byte) 0x14),
|
||||
POD_IN_ALARM((byte) 0x15),
|
||||
COMD_NOT_SET((byte) 0x16),
|
||||
ILLEGAL_RX_SENS_VALUE((byte) 0x17),
|
||||
ILLEGAL_TX_PKT_SIZE((byte) 0x18),
|
||||
OCCL_PARAMS_ALREADY_SET((byte) 0x19),
|
||||
OCCL_PARAM((byte) 0x1a),
|
||||
ILLEGAL_CDTHR_VALUE((byte) 0x1b),
|
||||
IGNORE_COMMAND((byte) 0x1c),
|
||||
INVALID_CRC((byte) 0x1d),
|
||||
UNKNOWN((byte) 0xff);
|
||||
|
||||
private byte value;
|
||||
|
||||
NakErrorType(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static NakErrorType byValue(byte value) {
|
||||
for (NakErrorType type : values()) {
|
||||
if (type.value == value) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
|
||||
|
||||
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.NakErrorType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus;
|
||||
|
||||
public class NakResponse extends ResponseBase {
|
||||
private final byte messageType;
|
||||
private final short messageLength;
|
||||
private final NakErrorType nakErrorType;
|
||||
private final AlarmType alarmType;
|
||||
private final PodStatus podStatus;
|
||||
private final short securityNakSyncCount;
|
||||
|
||||
public NakResponse(byte[] encoded) {
|
||||
super(ResponseType.NAK_RESPONSE, encoded);
|
||||
this.messageType = encoded[0];
|
||||
this.messageLength = encoded[1];
|
||||
this.nakErrorType = NakErrorType.byValue(encoded[2]);
|
||||
byte byte3 = encoded[3];
|
||||
byte byte4 = encoded[4];
|
||||
if (nakErrorType == NakErrorType.ILLEGAL_SECURITY_CODE) {
|
||||
this.securityNakSyncCount = (short) ((byte3 << 8) | byte4);
|
||||
this.alarmType = null;
|
||||
this.podStatus = null;
|
||||
} else {
|
||||
this.securityNakSyncCount = 0;
|
||||
this.alarmType = AlarmType.byValue(byte3);
|
||||
this.podStatus = PodStatus.byValue(byte4);
|
||||
}
|
||||
}
|
||||
|
||||
public byte getMessageType() {
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public short getMessageLength() {
|
||||
return messageLength;
|
||||
}
|
||||
|
||||
public NakErrorType getNakErrorType() {
|
||||
return nakErrorType;
|
||||
}
|
||||
|
||||
public AlarmType getAlarmType() {
|
||||
return alarmType;
|
||||
}
|
||||
|
||||
public PodStatus getPodStatus() {
|
||||
return podStatus;
|
||||
}
|
||||
|
||||
public short getSecurityNakSyncCount() {
|
||||
return securityNakSyncCount;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "NakResponse{" +
|
||||
"messageType=" + messageType +
|
||||
", messageLength=" + messageLength +
|
||||
", nakErrorType=" + nakErrorType +
|
||||
", alarmType=" + alarmType +
|
||||
", podStatus=" + podStatus +
|
||||
", securityNakSyncCount=" + securityNakSyncCount +
|
||||
", responseType=" + responseType +
|
||||
", encoded=" + Arrays.toString(encoded) +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response;
|
||||
|
||||
// TODO capture NAK response
|
||||
public class NakResponseTest {
|
||||
}
|
Loading…
Reference in a new issue