Skip to content
Snippets Groups Projects
Commit 17c3f544 authored by Lennart Goedhart's avatar Lennart Goedhart
Browse files

Commit working version of Uploader before refactoring messages to be "classier".

parent f1c29832
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -4,8 +4,8 @@ import android.util.Log; ...@@ -4,8 +4,8 @@ import android.util.Log;
import com.nightscout.android.USB.UsbHidDriver; import com.nightscout.android.USB.UsbHidDriver;
import com.nightscout.android.dexcom.USB.HexDump; import com.nightscout.android.dexcom.USB.HexDump;
import com.nightscout.android.medtronic.message.ContourNextLinkBinaryMessage;
import com.nightscout.android.medtronic.message.ChannelNegotiateMessage; import com.nightscout.android.medtronic.message.ChannelNegotiateMessage;
import com.nightscout.android.medtronic.message.ContourNextLinkBinaryMessage;
import com.nightscout.android.medtronic.service.MedtronicCNLService; import com.nightscout.android.medtronic.service.MedtronicCNLService;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -24,25 +24,9 @@ public class MedtronicCNLReader { ...@@ -24,25 +24,9 @@ public class MedtronicCNLReader {
private static final String BAYER_USB_HEADER = "ABC"; private static final String BAYER_USB_HEADER = "ABC";
private static final byte[] RADIO_CHANNELS = { 0x14, 0x11, 0x0e, 0x17, 0x1a }; private static final byte[] RADIO_CHANNELS = { 0x14, 0x11, 0x0e, 0x17, 0x1a };
public String deviceInfo;
public enum ASCII {
STX(0x02),
EOT(0x04),
ENQ(0x05),
ACK(0x06),
NAK(0x15);
private byte value;
ASCII(int code) {
this.value = (byte) code;
}
}
private UsbHidDriver mDevice; private UsbHidDriver mDevice;
private MedtronicCNLSession mPumpSession = new MedtronicCNLSession(); private MedtronicCNLSession mPumpSession = new MedtronicCNLSession();
public String deviceInfo;
public MedtronicCNLReader(UsbHidDriver device) { public MedtronicCNLReader(UsbHidDriver device) {
mDevice = device; mDevice = device;
} }
...@@ -51,8 +35,8 @@ public class MedtronicCNLReader { ...@@ -51,8 +35,8 @@ public class MedtronicCNLReader {
ByteArrayOutputStream responseMessage = new ByteArrayOutputStream(); ByteArrayOutputStream responseMessage = new ByteArrayOutputStream();
byte[] responseBuffer = new byte[USB_BLOCKSIZE]; byte[] responseBuffer = new byte[USB_BLOCKSIZE];
int bytesRead = 0; int bytesRead;
int messageSize = 0; int messageSize;
do { do {
bytesRead = mDevice.read(responseBuffer, READ_TIMEOUT_MS); bytesRead = mDevice.read(responseBuffer, READ_TIMEOUT_MS);
...@@ -133,7 +117,7 @@ public class MedtronicCNLReader { ...@@ -133,7 +117,7 @@ public class MedtronicCNLReader {
public void openConnection() throws IOException { public void openConnection() throws IOException {
ContourNextLinkBinaryMessage message = new ContourNextLinkBinaryMessage(ContourNextLinkBinaryMessage.CommandType.OPEN_CONNECTION, mPumpSession, mPumpSession.getHMAC()); ContourNextLinkBinaryMessage message = new ContourNextLinkBinaryMessage(ContourNextLinkBinaryMessage.CommandType.OPEN_CONNECTION, mPumpSession, mPumpSession.getHMAC());
message.send(this); //message.send(this);
sendMessage(message.encode()); sendMessage(message.encode());
// FIXME - We need to care what the response message is - wrong MAC and all that // FIXME - We need to care what the response message is - wrong MAC and all that
readMessage(); readMessage();
...@@ -152,4 +136,18 @@ public class MedtronicCNLReader { ...@@ -152,4 +136,18 @@ public class MedtronicCNLReader {
sendMessage(message.encode()); sendMessage(message.encode());
} }
} }
public enum ASCII {
STX(0x02),
EOT(0x04),
ENQ(0x05),
ACK(0x06),
NAK(0x15);
private byte value;
ASCII(int code) {
this.value = (byte) code;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment