Skip to content
Snippets Groups Projects
Commit afb92d4e authored by Pogman's avatar Pogman
Browse files

RSSI status added (found as part of Negotiate Channel Response from Pump)

Shows user percentage feedback of radio signal to help them diagnose reception issues.

RSSI (Recieved Signal Strength Indicator) is a common name for the signal strength in a wireless network environment. It is a measure of the power level that a RF client device is receiving from an access point, for example.
parent 8e9511f0
No related branches found
No related tags found
No related merge requests found
...@@ -150,9 +150,11 @@ public class MedtronicCnlReader { ...@@ -150,9 +150,11 @@ public class MedtronicCnlReader {
ChannelNegotiateResponseMessage response = new ChannelNegotiateRequestMessage(mPumpSession).send(mDevice); ChannelNegotiateResponseMessage response = new ChannelNegotiateRequestMessage(mPumpSession).send(mDevice);
if (response.getRadioChannel() == mPumpSession.getRadioChannel()) { if (response.getRadioChannel() == mPumpSession.getRadioChannel()) {
mPumpSession.setRadioRSSI(response.getRadioRSSI());
break; break;
} else { } else {
mPumpSession.setRadioChannel((byte)0); mPumpSession.setRadioChannel((byte)0);
mPumpSession.setRadioRSSI((byte)0);
} }
} }
......
...@@ -20,6 +20,8 @@ public class MedtronicCnlSession { ...@@ -20,6 +20,8 @@ public class MedtronicCnlSession {
private long pumpMAC; private long pumpMAC;
private byte radioChannel; private byte radioChannel;
private byte radioRSSI;
private int bayerSequenceNumber = 1; private int bayerSequenceNumber = 1;
private int medtronicSequenceNumber = 1; private int medtronicSequenceNumber = 1;
...@@ -80,6 +82,14 @@ public class MedtronicCnlSession { ...@@ -80,6 +82,14 @@ public class MedtronicCnlSession {
return radioChannel; return radioChannel;
} }
public byte getRadioRSSI() {
return radioRSSI;
}
public int getRadioRSSIpercentage() {
return (((int) radioRSSI & 0x00FF) * 100) / 0xA8;
}
public void incrBayerSequenceNumber() { public void incrBayerSequenceNumber() {
bayerSequenceNumber++; bayerSequenceNumber++;
} }
...@@ -92,6 +102,10 @@ public class MedtronicCnlSession { ...@@ -92,6 +102,10 @@ public class MedtronicCnlSession {
this.radioChannel = radioChannel; this.radioChannel = radioChannel;
} }
public void setRadioRSSI(byte radioRSSI) {
this.radioRSSI = radioRSSI;
}
public void setHMAC(byte[] hmac) { public void setHMAC(byte[] hmac) {
this.HMAC = hmac; this.HMAC = hmac;
} }
......
...@@ -16,6 +16,7 @@ public class ChannelNegotiateResponseMessage extends ContourNextLinkBinaryRespon ...@@ -16,6 +16,7 @@ public class ChannelNegotiateResponseMessage extends ContourNextLinkBinaryRespon
private static final String TAG = ChannelNegotiateResponseMessage.class.getSimpleName(); private static final String TAG = ChannelNegotiateResponseMessage.class.getSimpleName();
private byte radioChannel = 0; private byte radioChannel = 0;
private byte radioRSSI = 0;
protected ChannelNegotiateResponseMessage(MedtronicCnlSession pumpSession, byte[] payload) throws EncryptionException, ChecksumException, IOException { protected ChannelNegotiateResponseMessage(MedtronicCnlSession pumpSession, byte[] payload) throws EncryptionException, ChecksumException, IOException {
super(payload); super(payload);
...@@ -25,15 +26,21 @@ public class ChannelNegotiateResponseMessage extends ContourNextLinkBinaryRespon ...@@ -25,15 +26,21 @@ public class ChannelNegotiateResponseMessage extends ContourNextLinkBinaryRespon
Log.d(TAG, "negotiateChannel: Check response length"); Log.d(TAG, "negotiateChannel: Check response length");
if (responseBytes.length > 46) { if (responseBytes.length > 46) {
radioChannel = responseBytes[76]; radioChannel = responseBytes[76];
radioRSSI = responseBytes[59];
if (responseBytes[76] != pumpSession.getRadioChannel()) { if (responseBytes[76] != pumpSession.getRadioChannel()) {
throw new IOException(String.format(Locale.getDefault(), "Expected to get a message for channel %d. Got %d", pumpSession.getRadioChannel(), responseBytes[76])); throw new IOException(String.format(Locale.getDefault(), "Expected to get a message for channel %d. Got %d", pumpSession.getRadioChannel(), responseBytes[76]));
} }
} else { } else {
radioChannel = ((byte) 0); radioChannel = ((byte) 0);
radioRSSI = ((byte) 0);
} }
} }
public byte getRadioChannel() { public byte getRadioChannel() {
return radioChannel; return radioChannel;
} }
public byte getRadioRSSI() {
return radioRSSI;
}
} }
...@@ -213,7 +213,8 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -213,7 +213,8 @@ public class MedtronicCnlIntentService extends IntentService {
} else { } else {
setActivePumpMac(pumpMAC); setActivePumpMac(pumpMAC);
activePump.setLastRadioChannel(radioChannel); activePump.setLastRadioChannel(radioChannel);
sendStatus(String.format(Locale.getDefault(), "Connected to Contour Next Link on channel %d.", (int) radioChannel)); //sendStatus(String.format(Locale.getDefault(), "Connected to Contour Next Link on channel %d.", (int) radioChannel));
sendStatus(String.format(Locale.getDefault(), "Connected on channel %d RSSI: %d%%", (int) radioChannel, cnlReader.getPumpSession().getRadioRSSIpercentage()));
Log.d(TAG, String.format("Connected to Contour Next Link on channel %d.", (int) radioChannel)); Log.d(TAG, String.format("Connected to Contour Next Link on channel %d.", (int) radioChannel));
cnlReader.beginEHSMSession(); cnlReader.beginEHSMSession();
......
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