don't set time on large diff, just warn

This commit is contained in:
AdrianLxM 2018-06-24 13:27:55 +02:00
parent f7609317ba
commit 3e53c66365
2 changed files with 8 additions and 7 deletions

View file

@ -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;
}

View file

@ -1175,7 +1175,7 @@
<string name="custom">Custom</string>
<string name="key_lockscreen" translatable="false">lockscreen</string>
<string name="largetimedifftitle">Large Time Difference</string>
<string name="largetimediff">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.</string>
<string name="largetimediff">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.</string>
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
<plurals name="objective_days">