From 54e647bbe1be94b305b2dd1a0f64717f044b6304 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 24 Jun 2018 15:43:42 +0200 Subject: [PATCH] re-initialize after time-sync --- .../plugins/PumpDanaRS/services/DanaRSService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index 13a367f9fd..ff4203fd7b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -153,8 +153,7 @@ public class DanaRSService extends Service { MainApp.instance().startActivity(i); //deinitialize pump - DanaRPump.reset(); - danaRPump = DanaRPump.getInstance(); + danaRPump.lastConnection = 0; MainApp.bus().post(new EventDanaRNewStatus()); MainApp.bus().post(new EventInitializationChanged()); return; @@ -167,6 +166,7 @@ public class DanaRSService extends Service { log.debug("Pump time difference: " + timeDiff + " seconds"); } } + danaRPump.lastConnection = System.currentTimeMillis(); long now = System.currentTimeMillis(); if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) { @@ -203,6 +203,13 @@ public class DanaRSService extends Service { } public PumpEnactResult loadEvents() { + + if(!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()){ + PumpEnactResult result = new PumpEnactResult().success(false); + result.comment = "pump not initialized"; + return result; + } + DanaRS_Packet_APS_History_Events msg; if (lastHistoryFetched == 0) { msg = new DanaRS_Packet_APS_History_Events(0);