- changed TimeDateOrTZChangeReceiver, to not reach on date change (bug), and extended detections (and also logs)...
- Pump drivers will now be notified that there was time/timezone change with more details. TimeChangeType is sent that tells if change was TZ or DST Start/End or Time change - added setting to Omnipod settings, that can disable event - partitial fix for #55
This commit is contained in:
parent
443018d433
commit
bba4c36294
18 changed files with 117 additions and 39 deletions
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 04.06.2016.
|
* Created by mike on 04.06.2016.
|
||||||
|
@ -96,8 +97,9 @@ public interface PumpInterface {
|
||||||
/**
|
/**
|
||||||
* This method will be called when time or Timezone changes, and pump driver can then do a specific action (for
|
* This method will be called when time or Timezone changes, and pump driver can then do a specific action (for
|
||||||
* example update clock on pump).
|
* example update clock on pump).
|
||||||
|
* @param timeChangeType
|
||||||
*/
|
*/
|
||||||
void timeDateOrTimeZoneChanged();
|
void timezoneOrDSTChanged(TimeChangeType timeChangeType);
|
||||||
|
|
||||||
/* Only used for pump types where hasFixedUnreachableAlert=true */
|
/* Only used for pump types where hasFixedUnreachableAlert=true */
|
||||||
default boolean isFixedUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
|
default boolean isFixedUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
|
||||||
|
|
|
@ -67,6 +67,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.InstanceId;
|
import info.nightscout.androidaps.utils.InstanceId;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -1390,7 +1391,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -477,7 +478,7 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 28.01.2018.
|
* Created by mike on 28.01.2018.
|
||||||
|
@ -506,7 +507,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -849,7 +850,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
public class LocalInsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface, InsightConnectionService.StateCallback {
|
public class LocalInsightPlugin extends PluginBase implements PumpInterface, ConstraintsInterface, InsightConnectionService.StateCallback {
|
||||||
|
|
||||||
|
@ -1624,7 +1625,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.InstanceId;
|
import info.nightscout.androidaps.utils.InstanceId;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,7 +280,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventCustomActionsChanged;
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
@ -48,7 +47,6 @@ import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperAc
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
|
@ -81,6 +79,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
||||||
|
|
||||||
|
@ -1606,7 +1605,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
||||||
|
|
|
@ -54,7 +54,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.pod
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
|
@ -71,6 +70,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -124,13 +124,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
displayConnectionMessages = false;
|
displayConnectionMessages = false;
|
||||||
|
|
||||||
|
//OmnipodUtil.setDriverState();
|
||||||
|
|
||||||
|
// TODO loop
|
||||||
if (OmnipodUtil.isOmnipodEros()) {
|
// if (OmnipodUtil.isOmnipodEros()) {
|
||||||
OmnipodUtil.setPlugin(this);
|
// OmnipodUtil.setPlugin(this);
|
||||||
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||||
OmnipodUtil.setPumpType(PumpType.Insulet_Omnipod);
|
// OmnipodUtil.setPumpType(PumpType.Insulet_Omnipod);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// // TODO ccc
|
// // TODO ccc
|
||||||
// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
// OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||||
|
@ -202,7 +203,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
(event.isChanged(R.string.key_omnipod_beep_bolus_enabled)) ||
|
(event.isChanged(R.string.key_omnipod_beep_bolus_enabled)) ||
|
||||||
(event.isChanged(R.string.key_omnipod_beep_tbr_enabled)) ||
|
(event.isChanged(R.string.key_omnipod_beep_tbr_enabled)) ||
|
||||||
(event.isChanged(R.string.key_omnipod_pod_debugging_options_enabled)) ||
|
(event.isChanged(R.string.key_omnipod_pod_debugging_options_enabled)) ||
|
||||||
(event.isChanged(R.string.key_omnipod_beep_smb_enabled)))
|
(event.isChanged(R.string.key_omnipod_beep_smb_enabled)) ||
|
||||||
|
(event.isChanged(R.string.key_omnipod_timechange_enabled)))
|
||||||
refreshConfiguration();
|
refreshConfiguration();
|
||||||
}, FabricPrivacy::logException)
|
}, FabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
|
@ -488,7 +490,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAvailable);
|
//OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAvailable);
|
||||||
// we would probably need to read Basal Profile here too
|
// we would probably need to read Basal Profile here too
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,13 +961,18 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType={}, eventHandlingEnabled={}]", timeChangeType.name(), pumpStatusLocal.timeChangeEventEnabled);
|
||||||
|
|
||||||
|
if (OmnipodUtil.getDriverState()==OmnipodDriverState.Initalized_PodAvailable) {
|
||||||
|
if (pumpStatusLocal.timeChangeEventEnabled) {
|
||||||
|
LOG.info(getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver.");
|
||||||
this.hasTimeDateOrTimeZoneChanged = true;
|
this.hasTimeDateOrTimeZoneChanged = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setEnableCustomAction(OmnipodCustomActionType customAction, boolean isEnabled) {
|
public void setEnableCustomAction(OmnipodCustomActionType customAction, boolean isEnabled) {
|
||||||
|
|
|
@ -245,6 +245,8 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
|
|
||||||
|
|
||||||
private void setValue(PodHistory historyEntry, TextView valueView) {
|
private void setValue(PodHistory historyEntry, TextView valueView) {
|
||||||
|
//valueView.setText("");
|
||||||
|
|
||||||
if (historyEntry.isSuccess()) {
|
if (historyEntry.isSuccess()) {
|
||||||
switch (historyEntry.getPodDbEntryType()) {
|
switch (historyEntry.getPodDbEntryType()) {
|
||||||
|
|
||||||
|
@ -262,13 +264,6 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetPodStatus:
|
|
||||||
break;
|
|
||||||
case GetPodInfo:
|
|
||||||
break;
|
|
||||||
case SetTime:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SetBolus: {
|
case SetBolus: {
|
||||||
if (historyEntry.getData().contains(";")) {
|
if (historyEntry.getData().contains(";")) {
|
||||||
String[] splitVal = historyEntry.getData().split(";");
|
String[] splitVal = historyEntry.getData().split(";");
|
||||||
|
@ -279,6 +274,9 @@ public class PodHistoryActivity extends NoSplashActivity {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GetPodStatus:
|
||||||
|
case GetPodInfo:
|
||||||
|
case SetTime:
|
||||||
case PairAndPrime:
|
case PairAndPrime:
|
||||||
case CancelTemporaryBasal:
|
case CancelTemporaryBasal:
|
||||||
case CancelTemporaryBasalForce:
|
case CancelTemporaryBasalForce:
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public boolean beepTBREnabled = true;
|
public boolean beepTBREnabled = true;
|
||||||
public boolean podDebuggingOptionsEnabled = false;
|
public boolean podDebuggingOptionsEnabled = false;
|
||||||
public String podLotNumber = "???";
|
public String podLotNumber = "???";
|
||||||
|
public boolean timeChangeEventEnabled = true;
|
||||||
|
|
||||||
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
|
this.beepSMBEnabled = SP.getBoolean(OmnipodConst.Prefs.BeepSMBEnabled, true);
|
||||||
this.beepTBREnabled = SP.getBoolean(OmnipodConst.Prefs.BeepTBREnabled, true);
|
this.beepTBREnabled = SP.getBoolean(OmnipodConst.Prefs.BeepTBREnabled, true);
|
||||||
this.podDebuggingOptionsEnabled = SP.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
|
this.podDebuggingOptionsEnabled = SP.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
|
||||||
|
this.timeChangeEventEnabled = SP.getBoolean(OmnipodConst.Prefs.TimeChangeEventEnabled, true);
|
||||||
|
|
||||||
LOG.debug("Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.beepBasalEnabled, this.beepBolusEnabled, this.beepSMBEnabled, this.beepTBREnabled);
|
LOG.debug("Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.beepBasalEnabled, this.beepBolusEnabled, this.beepSMBEnabled, this.beepTBREnabled);
|
||||||
|
|
||||||
|
|
|
@ -19,17 +19,18 @@ public class OmnipodConst {
|
||||||
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled;
|
public static final int BeepSMBEnabled = R.string.key_omnipod_beep_smb_enabled;
|
||||||
public static final int BeepTBREnabled = R.string.key_omnipod_beep_tbr_enabled;
|
public static final int BeepTBREnabled = R.string.key_omnipod_beep_tbr_enabled;
|
||||||
public static final int PodDebuggingOptionsEnabled = R.string.key_omnipod_pod_debugging_options_enabled;
|
public static final int PodDebuggingOptionsEnabled = R.string.key_omnipod_pod_debugging_options_enabled;
|
||||||
|
public static final int TimeChangeEventEnabled = R.string.key_omnipod_timechange_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Statistics {
|
public class Statistics {
|
||||||
public static final String StatsPrefix = "omnipod_";
|
public static final String StatsPrefix = "omnipod_";
|
||||||
public static final String FirstPumpStart = Prefix + "first_pump_use";
|
public static final String FirstPumpStart = Prefix + "first_pump_use";
|
||||||
public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime";
|
public static final String LastGoodPumpCommunicationTime = Prefix + "lastGoodPumpCommunicationTime";
|
||||||
public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency";
|
//public static final String LastGoodPumpFrequency = Prefix + "LastGoodPumpFrequency";
|
||||||
public static final String TBRsSet = StatsPrefix + "tbrs_set";
|
public static final String TBRsSet = StatsPrefix + "tbrs_set";
|
||||||
public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered";
|
public static final String StandardBoluses = StatsPrefix + "std_boluses_delivered";
|
||||||
public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered";
|
public static final String SMBBoluses = StatsPrefix + "smb_boluses_delivered";
|
||||||
public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry";
|
//public static final String LastPumpHistoryEntry = StatsPrefix + "pump_history_entry";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final double POD_PULSE_SIZE = 0.05;
|
public static final double POD_PULSE_SIZE = 0.05;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashCommunicationManager;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 23.04.18.
|
* Created by andy on 23.04.18.
|
||||||
|
@ -284,7 +285,7 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
// LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
// LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
||||||
|
|
|
@ -42,6 +42,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.InstanceId;
|
import info.nightscout.androidaps.utils.InstanceId;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -504,7 +505,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeDateOrTimeZoneChanged() {
|
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.receivers;
|
package info.nightscout.androidaps.receivers;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -9,37 +8,84 @@ import android.content.IntentFilter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||||
|
|
||||||
public class TimeDateOrTZChangeReceiver extends BroadcastReceiver {
|
public class TimeDateOrTZChangeReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
|
||||||
|
private boolean isDST;
|
||||||
|
|
||||||
|
public TimeDateOrTZChangeReceiver() {
|
||||||
|
isDST = calculateDST();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean calculateDST() {
|
||||||
|
TimeZone timeZone = TimeZone.getDefault();
|
||||||
|
Date nowDate = new Date();
|
||||||
|
|
||||||
|
if (timeZone.useDaylightTime()) {
|
||||||
|
return (timeZone.inDaylightTime(nowDate));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
|
|
||||||
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
|
|
||||||
LOG.debug("Date, Time and/or TimeZone changed.");
|
if (activePump==null) {
|
||||||
|
LOG.debug("TimeDateOrTZChangeReceiver::Time and/or TimeZone changed. [action={}]. Pump is null, exiting.", action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.debug("TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action);
|
||||||
LOG.debug("TimeDateOrTZChangeReceiver::Intent::{}", OmnipodUtil.getGsonInstance().toJson(intent));
|
LOG.debug("TimeDateOrTZChangeReceiver::Intent::{}", OmnipodUtil.getGsonInstance().toJson(intent));
|
||||||
|
|
||||||
if (action != null && activePump != null) {
|
if (action==null) {
|
||||||
LOG.debug("Date, Time and/or TimeZone changed. Notifying pump driver.");
|
LOG.error("TimeDateOrTZChangeReceiver::Action is null. Exiting.");
|
||||||
activePump.timeDateOrTimeZoneChanged();
|
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(action)) {
|
||||||
|
LOG.info("TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.");
|
||||||
|
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange);
|
||||||
|
} else if (Intent.ACTION_TIME_CHANGED.equals(action)) {
|
||||||
|
boolean currentDst = calculateDST();
|
||||||
|
|
||||||
|
if (currentDst==isDST) {
|
||||||
|
LOG.info("TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.");
|
||||||
|
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange);
|
||||||
|
} else {
|
||||||
|
if (currentDst) {
|
||||||
|
LOG.info("TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.");
|
||||||
|
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started);
|
||||||
|
} else {
|
||||||
|
LOG.info("TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.");
|
||||||
|
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDST = currentDst;
|
||||||
|
} else {
|
||||||
|
LOG.error("TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void registerBroadcasts(MainApp mainApp) {
|
public void registerBroadcasts(MainApp mainApp) {
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
//filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
mainApp.registerReceiver(this, filter);
|
mainApp.registerReceiver(this, filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
|
public enum TimeChangeType {
|
||||||
|
TimezoneChange,
|
||||||
|
DST_Started,
|
||||||
|
DST_Ended,
|
||||||
|
ManualTimeChange
|
||||||
|
}
|
|
@ -1652,11 +1652,13 @@
|
||||||
<string name="key_omnipod_beep_smb_enabled" translatable="false">pref_omnipod_beep_smb_enabled</string>
|
<string name="key_omnipod_beep_smb_enabled" translatable="false">pref_omnipod_beep_smb_enabled</string>
|
||||||
<string name="key_omnipod_beep_tbr_enabled" translatable="false">pref_omnipod_beep_tbr_enabled</string>
|
<string name="key_omnipod_beep_tbr_enabled" translatable="false">pref_omnipod_beep_tbr_enabled</string>
|
||||||
<string name="key_omnipod_pod_debugging_options_enabled" translatable="false">pref_omnipod_pod_debugging_options_enabled</string>
|
<string name="key_omnipod_pod_debugging_options_enabled" translatable="false">pref_omnipod_pod_debugging_options_enabled</string>
|
||||||
|
<string name="key_omnipod_timechange_enabled" translatable="false">pref_omnipod_timechange_enabled</string>
|
||||||
<string name="omnipod_config_beep_bolus_enabled">Bolus Beep Enabled</string>
|
<string name="omnipod_config_beep_bolus_enabled">Bolus Beep Enabled</string>
|
||||||
<string name="omnipod_config_beep_basal_enabled">Basal Beep Enabled</string>
|
<string name="omnipod_config_beep_basal_enabled">Basal Beep Enabled</string>
|
||||||
<string name="omnipod_config_beep_smb_enabled">SMB Beep Enabled</string>
|
<string name="omnipod_config_beep_smb_enabled">SMB Beep Enabled</string>
|
||||||
<string name="omnipod_config_beep_tbr_enabled">TBR Beep Enabled</string>
|
<string name="omnipod_config_beep_tbr_enabled">TBR Beep Enabled</string>
|
||||||
<string name="omnipod_config_pod_debugging_options_enabled">Pod Debugging Options Enabled</string>
|
<string name="omnipod_config_pod_debugging_options_enabled">Pod Debugging Options Enabled</string>
|
||||||
|
<string name="omnipod_config_timechange_enabled">DST/Timezone Detection Enabled</string>
|
||||||
|
|
||||||
<!-- Omnipod - Fragment -->
|
<!-- Omnipod - Fragment -->
|
||||||
<string name="omnipod_pod_mgmt">Pod Mgmt</string>
|
<string name="omnipod_pod_mgmt">Pod Mgmt</string>
|
||||||
|
|
|
@ -36,5 +36,10 @@
|
||||||
android:key="@string/key_omnipod_pod_debugging_options_enabled"
|
android:key="@string/key_omnipod_pod_debugging_options_enabled"
|
||||||
android:title="@string/omnipod_config_pod_debugging_options_enabled" />
|
android:title="@string/omnipod_config_pod_debugging_options_enabled" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="@string/key_omnipod_timechange_enabled"
|
||||||
|
android:title="@string/omnipod_config_pod_debugging_options_enabled" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in a new issue