diff --git a/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java b/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java index 220ba9f2db5213d998fd4ca935afdcc7a39418c5..b7bab7f77977a1aa26fafa512d3fc32ab56f05fc 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java +++ b/app/src/main/java/info/nightscout/android/medtronic/MainActivity.java @@ -629,13 +629,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc return; } - PumpStatusEvent pumpStatusData = pump.getPumpHistory().last();; - lastQueryTS = pump.getLastQueryTS(); -// >>>>> note: prototype smart poll handling added to cnl intent -// startCgmService(MainActivity.getNextPoll(pumpStatusData)); - // Delete invalid or old records from Realm // TODO - show an error message if the valid records haven't been uploaded final RealmResults<PumpStatusEvent> results = @@ -657,10 +652,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc } // TODO - handle isOffline in NightscoutUploadIntentService? - - // >>>>> check this out as it's uploading before cnl comms finishes and may cause occasional channel changes due to wifi noise - cnl intent handles ns upload trigger after all comms finish - // uploadCgmData(); - refreshDisplay(); } }); @@ -758,7 +749,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc PumpInfo pump = getActivePump(); - if (pump != null && pump.isValid()) { + if (pump != null && pump.isValid() && pump.getPumpHistory().size() > 0) { Log.d(TAG, "history display refresh size: " + pump.getPumpHistory().size()); Log.d(TAG, "history display refresh date: " + pump.getPumpHistory().last().getEventDate()); pumpStatusData = pump.getPumpHistory().last(); diff --git a/app/src/main/java/info/nightscout/android/medtronic/message/PumpStatusResponseMessage.java b/app/src/main/java/info/nightscout/android/medtronic/message/PumpStatusResponseMessage.java index 4b591cc75c93bbe5106f9c8229307eceaae023fb..68c60b7707bc3147d341a7b7e4849477f681e031 100644 --- a/app/src/main/java/info/nightscout/android/medtronic/message/PumpStatusResponseMessage.java +++ b/app/src/main/java/info/nightscout/android/medtronic/message/PumpStatusResponseMessage.java @@ -143,9 +143,8 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa * update pumpRecord with data read from pump * * @param pumpRecord - * @param pumpOffset */ - public void updatePumpRecord(PumpStatusEvent pumpRecord, long pumpOffset) { + public void updatePumpRecord(PumpStatusEvent pumpRecord) { // Status Flags pumpRecord.setSuspended(suspended); pumpRecord.setBolusing(bolusing); @@ -188,7 +187,7 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa // SGV Date pumpRecord.setCgmTrend(cgmTrend); - pumpRecord.setEventDate(new Date(sgvDate.getTime() - pumpOffset)); + pumpRecord.setEventDate(new Date(sgvDate.getTime() - pumpRecord.getPumpTimeOffset())); // Predictive low suspend // TODO - there is more status info in this byte other than just a boolean yes/no diff --git a/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpInfo.java b/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpInfo.java index dac3391fc883cfb4cf6806b1aad6ca4e74fd016f..f7d864da473096c2cabf1f20e4b81930efbb0593 100644 --- a/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpInfo.java +++ b/app/src/main/java/info/nightscout/android/model/medtronicNg/PumpInfo.java @@ -16,7 +16,7 @@ public class PumpInfo extends RealmObject { private byte lastRadioChannel; private long lastQueryTS = 0; private RealmList<ContourNextLinkInfo> associatedCnls; - private RealmList<PumpStatusEvent> pumpHistory; + private RealmList<PumpStatusEvent> pumpHistory = new RealmList<>(); public long getPumpMac() { return pumpMac;