From 3e53c66365e466521883e9c37605842f735fec03 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 24 Jun 2018 13:27:55 +0200 Subject: [PATCH] don't set time on large diff, just warn --- .../plugins/PumpDanaRS/services/DanaRSService.java | 13 +++++++------ app/src/main/res/values/strings.xml | 2 +- 2 files changed, 8 insertions(+), 7 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 13a14e77c8..afb1392369 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,9 +153,6 @@ public class DanaRSService extends Service { long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; log.debug("Pump time difference: " + timeDiff + " seconds"); if (Math.abs(timeDiff) > 3) { - waitForWholeMinute(); // Dana can set only whole minute - // add 10sec to be sure we are over minute (will be cutted off anyway) - bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs()))); if (Math.abs(timeDiff) > 60*60*1.5) { //If time-diff is very large, warn user until we can synchronize history readings properly Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class); @@ -164,10 +161,14 @@ public class DanaRSService extends Service { i.putExtra("title", MainApp.gs(R.string.largetimedifftitle)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); MainApp.instance().startActivity(i); + } else { + waitForWholeMinute(); // Dana can set only whole minute + // add 10sec to be sure we are over minute (will be cutted off anyway) + bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs()))); + bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); + timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; + log.debug("Pump time difference: " + timeDiff + " seconds"); } - bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); - timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L; - log.debug("Pump time difference: " + timeDiff + " seconds"); } danaRPump.lastSettingsRead = now; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 76df0c826e..51eefc246c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1175,7 +1175,7 @@ Custom lockscreen Large Time Difference - Large time difference: Time in pump was adjuted for more than 1.5 hours. Make sure that reading the history from the pump does not cause unexpected behaviour. + Large time difference:\nTime in pump is off by more than 1.5 hours.\nPlease adjust the time manually on the pump and make sure that reading the history from the pump does not cause unexpected behaviour.\nIf possible, remove the history from the pump before changing the time or disable the closed loop for one DIA after the last wrong history entry but minimum one DIA from now. Clean AndroidAPS started