diff --git a/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java b/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java index 22c888d1dbabeb951d17cbf78871f31606466f02..8dde933c07b0fb57bf6ff50367fd91e94e103644 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java +++ b/app/src/main/java/info/nightscout/android/medtronic/MedtronicCnlReader.java @@ -9,7 +9,6 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; -import java.util.Locale; import java.util.concurrent.TimeoutException; import info.nightscout.android.USB.UsbHidDriver; @@ -51,7 +50,7 @@ public class MedtronicCnlReader { private MedtronicCnlSession mPumpSession = new MedtronicCnlSession(); private String mStickSerial = null; - private static final int TIMEOUT_MS = 0; //500 note: using a read "pause" has no effect on outcome and likely redundant due to clearMessage intercepting unread messages + private static final int SLEEP_MS = 500; public MedtronicCnlReader(UsbHidDriver device) { mDevice = device; @@ -80,9 +79,9 @@ public class MedtronicCnlReader { doRetry = false; try { new ContourNextLinkCommandMessage(ContourNextLinkCommandMessage.ASCII.NAK) - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.EOT); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.EOT); new ContourNextLinkCommandMessage(ContourNextLinkCommandMessage.ASCII.ENQ) - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); } catch (UnexpectedMessageException e2) { try { new ContourNextLinkCommandMessage(ContourNextLinkCommandMessage.ASCII.EOT).send(mDevice); @@ -97,11 +96,11 @@ public class MedtronicCnlReader { public void enterPassthroughMode() throws IOException, TimeoutException, UnexpectedMessageException, ChecksumException, EncryptionException { Log.d(TAG, "Begin enterPasshtroughMode"); new ContourNextLinkCommandMessage("W|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); new ContourNextLinkCommandMessage("Q|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); new ContourNextLinkCommandMessage("1|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); Log.d(TAG, "Finished enterPasshtroughMode"); } @@ -226,18 +225,18 @@ public class MedtronicCnlReader { public void endPassthroughMode() throws IOException, TimeoutException, UnexpectedMessageException, ChecksumException, EncryptionException { Log.d(TAG, "Begin endPassthroughMode"); new ContourNextLinkCommandMessage("W|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); new ContourNextLinkCommandMessage("Q|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); new ContourNextLinkCommandMessage("0|") - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ACK); Log.d(TAG, "Finished endPassthroughMode"); } public void endControlMode() throws IOException, TimeoutException, UnexpectedMessageException, ChecksumException, EncryptionException { Log.d(TAG, "Begin endControlMode"); new ContourNextLinkCommandMessage(ContourNextLinkCommandMessage.ASCII.EOT) - .send(mDevice, TIMEOUT_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ENQ); + .send(mDevice, SLEEP_MS).checkControlMessage(ContourNextLinkCommandMessage.ASCII.ENQ); Log.d(TAG, "Finished endControlMode"); } }