Skip to content
Snippets Groups Projects
Commit bc822aa4 authored by Volker Richert's avatar Volker Richert
Browse files

refactoring

parent 7b2ad2fd
No related branches found
No related tags found
No related merge requests found
......@@ -164,14 +164,6 @@ public class MedtronicCnlReader implements ContourNextLinkMessageHandler {
}
}
// TODO - get rid of this - it should be in a message decoder
private void checkControlMessage(byte[] msg, byte controlCharacter) throws IOException, TimeoutException, UnexpectedMessageException {
if (msg.length != 1 || msg[0] != controlCharacter) {
throw new UnexpectedMessageException(String.format(Locale.getDefault(), "Expected to get control character '%d' Got '%d'.",
(int) controlCharacter, (int) msg[0]));
}
}
public void requestDeviceInfo()
throws IOException, TimeoutException, UnexpectedMessageException, ChecksumException, EncryptionException {
DeviceInfoResponseCommandMessage response = new DeviceInfoRequestCommandMessage().send(mDevice);
......
......@@ -17,7 +17,7 @@ public class ContourNextLinkBinaryMessage extends ContourNextLinkMessage {
//protected ByteBuffer mBayerPayload;
protected CommandType mCommandType = CommandType.NO_TYPE;
static int ENVELOPE_SIZE = 33;
private final static int ENVELOPE_SIZE = 33;
public enum CommandType {
NO_TYPE(0x0),
......
......@@ -115,5 +115,9 @@ public class ContourNextLinkMessage {
ASCII(int code) {
this.value = (byte) code;
}
public boolean equals(byte value) {
return this.value == value;
}
}
}
......@@ -25,14 +25,16 @@ public class DeviceInfoRequestCommandMessage extends ContourNextLinkMessage {
do {
try {
if (response1[0] == ASCII.EOT.value) {
if (ASCII.EOT.equals(response1[0])) {
// response 1 is the ASTM message
response = new DeviceInfoResponseCommandMessage(mPumpSession, response1);
response.checkControlMessage(response2, ASCII.ENQ.value);
// ugly....
response.checkControlMessage(response2, ASCII.ENQ);
} else {
// response 2 is the ASTM message
response = new DeviceInfoResponseCommandMessage(mPumpSession, response1);
response.checkControlMessage(response1, ASCII.ENQ.value);
// ugly, too....
response.checkControlMessage(response1, ASCII.ENQ);
}
} catch (TimeoutException e) {
doRetry = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment