Get Pod status after time change event and add notification when automatic time change fails

This commit is contained in:
Bart Sopers 2020-09-11 02:25:48 +02:00
parent df1731e6b7
commit 6070b117f4
2 changed files with 24 additions and 7 deletions

View file

@ -510,22 +510,38 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
} }
} else if (this.hasTimeDateOrTimeZoneChanged) { } else if (this.hasTimeDateOrTimeZoneChanged) {
PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TIME, aapsOmnipodManager::setTime); PumpEnactResult result;
if (aapsOmnipodManager.isTimeChangeEventEnabled()) {
result = executeCommand(OmnipodCommandType.SET_TIME, aapsOmnipodManager::setTime);
} else {
// Even if automatically changing the time is disabled, we still want to at least do a GetStatus request,
// in order to update the Pod's activation time, which we need for calculating the time on the Pod
result = executeCommand(OmnipodCommandType.GET_POD_STATUS, aapsOmnipodManager::getPodStatus);
}
if (result.success) { if (result.success) {
this.hasTimeDateOrTimeZoneChanged = false; this.hasTimeDateOrTimeZoneChanged = false;
timeChangeRetries = 0; timeChangeRetries = 0;
if (aapsOmnipodManager.isTimeChangeEventEnabled()) {
Notification notification = new Notification( Notification notification = new Notification(
Notification.TIME_OR_TIMEZONE_CHANGE, Notification.TIME_OR_TIMEZONE_CHANGE,
resourceHelper.gs(R.string.omnipod_time_or_timezone_change), resourceHelper.gs(R.string.omnipod_time_or_timezone_change),
Notification.INFO, 60); Notification.INFO, 60);
rxBus.send(new EventNewNotification(notification)); rxBus.send(new EventNewNotification(notification));
}
} else { } else {
timeChangeRetries++; timeChangeRetries++;
if (timeChangeRetries > 3) { if (timeChangeRetries > 3) {
if (aapsOmnipodManager.isTimeChangeEventEnabled()) {
Notification notification = new Notification(
Notification.TIME_OR_TIMEZONE_CHANGE,
resourceHelper.gs(R.string.omnipod_time_or_timezone_change_failed),
Notification.INFO, 60);
rxBus.send(new EventNewNotification(notification));
}
this.hasTimeDateOrTimeZoneChanged = false; this.hasTimeDateOrTimeZoneChanged = false;
timeChangeRetries = 0; timeChangeRetries = 0;
} }
@ -806,7 +822,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) { public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
aapsLogger.warn(LTag.PUMP, "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + aapsOmnipodManager.isTimeChangeEventEnabled() + "]"); aapsLogger.warn(LTag.PUMP, "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + aapsOmnipodManager.isTimeChangeEventEnabled() + "]");
if (aapsOmnipodManager.isTimeChangeEventEnabled() && podStateManager.isPodRunning()) { if (podStateManager.isPodRunning()) {
aapsLogger.info(LTag.PUMP, "Time, Date and/or TimeZone changed event received and will be consumed by driver."); aapsLogger.info(LTag.PUMP, "Time, Date and/or TimeZone changed event received and will be consumed by driver.");
this.hasTimeDateOrTimeZoneChanged = true; this.hasTimeDateOrTimeZoneChanged = true;
} }

View file

@ -162,6 +162,7 @@
<string name="omnipod_cmd_basal_profile_not_set_is_same">Basal profile is the same, so it will not be set again.</string> <string name="omnipod_cmd_basal_profile_not_set_is_same">Basal profile is the same, so it will not be set again.</string>
<string name="omnipod_custom_action_reset_rileylink">Reset RileyLink config</string> <string name="omnipod_custom_action_reset_rileylink">Reset RileyLink config</string>
<string name="omnipod_time_or_timezone_change">Time and/or time zone changed on the Pod</string> <string name="omnipod_time_or_timezone_change">Time and/or time zone changed on the Pod</string>
<string name="omnipod_time_or_timezone_change_failed">Failed to automatically change time and/or time zone on the Pod. You can manually synchronise the time on the Omnipod tab.</string>
<string name="omnipod_composite_time">%1$s and %2$s</string> <string name="omnipod_composite_time">%1$s and %2$s</string>
<string name="omnipod_time_ago">%1$s ago</string> <string name="omnipod_time_ago">%1$s ago</string>
<string name="omnipod_waiting_for_rileylink_connection">Waiting for RileyLink connection...</string> <string name="omnipod_waiting_for_rileylink_connection">Waiting for RileyLink connection...</string>