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

Add some temporary debug info to status to check long term stability for CNL handling

parent 88516e2b
No related branches found
No related tags found
No related merge requests found
...@@ -104,6 +104,14 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -104,6 +104,14 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
public static short pumpBattery = 0; public static short pumpBattery = 0;
public static int countUnavailableSGV = 0; public static int countUnavailableSGV = 0;
// temporary debug stats for CNL connections
public static int dbgCNL_enterControlMode = 0;
public static int dbgCNL_enterPassthroughMode = 0;
public static int dbgCNL_openConnection = 0;
public static int dbgCNL_beginEHSMSession = 0;
public static int dbgCNL_clearMessage = 0;
public static int dbgCNL_not0x81 = 0;
boolean mEnableCgmService = true; boolean mEnableCgmService = true;
SharedPreferences prefs = null; SharedPreferences prefs = null;
private PumpInfo mActivePump; private PumpInfo mActivePump;
......
...@@ -8,9 +8,7 @@ import java.nio.ByteBuffer; ...@@ -8,9 +8,7 @@ import java.nio.ByteBuffer;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import info.nightscout.android.USB.UsbHidDriver; import info.nightscout.android.USB.UsbHidDriver;
import info.nightscout.android.medtronic.exception.ChecksumException; import info.nightscout.android.medtronic.MainActivity;
import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.medtronic.exception.UnexpectedMessageException;
import info.nightscout.android.utils.HexDump; import info.nightscout.android.utils.HexDump;
/** /**
...@@ -154,6 +152,7 @@ public abstract class ContourNextLinkMessage { ...@@ -154,6 +152,7 @@ public abstract class ContourNextLinkMessage {
if (responseBytes[18] != (byte) 0x81) { if (responseBytes[18] != (byte) 0x81) {
doRetry = true; doRetry = true;
Log.d(TAG, "readMessage0x81: did not get 0x81 response, got " + responseBytes[18]); Log.d(TAG, "readMessage0x81: did not get 0x81 response, got " + responseBytes[18]);
MainActivity.dbgCNL_not0x81++;
} else { } else {
doRetry = false; doRetry = false;
responseSize = responseBytes.length; responseSize = responseBytes.length;
...@@ -186,6 +185,7 @@ public abstract class ContourNextLinkMessage { ...@@ -186,6 +185,7 @@ public abstract class ContourNextLinkMessage {
if (bytesClear > 0) { if (bytesClear > 0) {
Log.d(TAG, "clearMessage: message stream cleared bytes: " + bytesClear); Log.d(TAG, "clearMessage: message stream cleared bytes: " + bytesClear);
MainActivity.dbgCNL_clearMessage++;
} }
return bytesClear; return bytesClear;
......
...@@ -189,10 +189,14 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -189,10 +189,14 @@ public class MedtronicCnlIntentService extends IntentService {
cnlReader.getPumpSession().setStickSerial(info.getSerialNumber()); cnlReader.getPumpSession().setStickSerial(info.getSerialNumber());
cnlReader.enterControlMode(); cnlReader.enterControlMode();
MainActivity.dbgCNL_enterControlMode += 1;
try { try {
cnlReader.enterPassthroughMode(); cnlReader.enterPassthroughMode();
MainActivity.dbgCNL_enterPassthroughMode += 1;
cnlReader.openConnection(); cnlReader.openConnection();
MainActivity.dbgCNL_openConnection += 1;
cnlReader.requestReadInfo(); cnlReader.requestReadInfo();
String key = info.getKey(); String key = info.getKey();
...@@ -245,6 +249,7 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -245,6 +249,7 @@ public class MedtronicCnlIntentService extends IntentService {
MainActivity.timeLastEHSM = timePollStarted; MainActivity.timeLastEHSM = timePollStarted;
cnlReader.beginEHSMSession(); cnlReader.beginEHSMSession();
MainActivity.dbgCNL_beginEHSMSession += 1;
// read pump status // read pump status
PumpStatusEvent pumpRecord = realm.createObject(PumpStatusEvent.class); PumpStatusEvent pumpRecord = realm.createObject(PumpStatusEvent.class);
...@@ -265,6 +270,7 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -265,6 +270,7 @@ public class MedtronicCnlIntentService extends IntentService {
cnlReader.updatePumpStatus(pumpRecord); cnlReader.updatePumpStatus(pumpRecord);
cnlReader.endEHSMSession(); cnlReader.endEHSMSession();
MainActivity.dbgCNL_beginEHSMSession -= 1;
if (pumpRecord.getSgv() != 0) { if (pumpRecord.getSgv() != 0) {
...@@ -322,8 +328,11 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -322,8 +328,11 @@ public class MedtronicCnlIntentService extends IntentService {
} finally { } finally {
try { try {
cnlReader.closeConnection(); cnlReader.closeConnection();
MainActivity.dbgCNL_openConnection -= 1;
cnlReader.endPassthroughMode(); cnlReader.endPassthroughMode();
MainActivity.dbgCNL_enterPassthroughMode -= 1;
cnlReader.endControlMode(); cnlReader.endControlMode();
MainActivity.dbgCNL_enterControlMode -= 1;
} catch (NoSuchAlgorithmException e) {} } catch (NoSuchAlgorithmException e) {}
} }
...@@ -379,6 +388,11 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -379,6 +388,11 @@ public class MedtronicCnlIntentService extends IntentService {
MedtronicCnlAlarmManager.setAlarm(nextRequestedPollTime); MedtronicCnlAlarmManager.setAlarm(nextRequestedPollTime);
sendStatus("Next poll due at: " + df.format(nextRequestedPollTime)); sendStatus("Next poll due at: " + df.format(nextRequestedPollTime));
// temporary debug stats for CNL connections
if ((MainActivity.dbgCNL_enterControlMode + MainActivity.dbgCNL_enterPassthroughMode + MainActivity.dbgCNL_openConnection + MainActivity.dbgCNL_beginEHSMSession + MainActivity.dbgCNL_clearMessage + MainActivity.dbgCNL_not0x81) > 0) {
sendStatus("CM: " + MainActivity.dbgCNL_enterControlMode + " PT: " + MainActivity.dbgCNL_enterPassthroughMode + " OC: " + MainActivity.dbgCNL_openConnection + " EH: " + MainActivity.dbgCNL_beginEHSMSession + " U: " + MainActivity.dbgCNL_clearMessage + " X: " + MainActivity.dbgCNL_not0x81);
}
MedtronicCnlAlarmReceiver.completeWakefulIntent(intent); MedtronicCnlAlarmReceiver.completeWakefulIntent(intent);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment