diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/CancelDeliveryAction.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/CancelDeliveryAction.java index 91590272a5..9dc84d18ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/CancelDeliveryAction.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/CancelDeliveryAction.java @@ -7,10 +7,8 @@ import java.util.List; import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage; -import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.BeepConfigCommand; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; -import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepConfigType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.BeepType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; @@ -38,18 +36,18 @@ public class CancelDeliveryAction implements OmnipodAction { public StatusResponse execute(OmnipodCommunicationService communicationService) { List messageBlocks = new ArrayList<>(); - messageBlocks.add(new CancelDeliveryCommand(podState.getCurrentNonce(), - acknowledgementBeep && deliveryTypes.size() == 1 ? BeepType.BEEP : BeepType.NO_BEEP, deliveryTypes)); - if (acknowledgementBeep && deliveryTypes.size() > 1) { - // Workaround for strange beep behaviour when cancelling multiple delivery types at the same time + // Workaround for strange beep behaviour when cancelling multiple delivery types + List deliveryTypeList = new ArrayList<>(deliveryTypes); - // FIXME we should use other constructor with all beep configs. - // Theoretically, if we would cancel multiple delivery types but not all, - // we should keep the beep config for delivery types that we're not cancelling. - // We currently have no use case that though, - // as we either cancel 1 type or all types, - messageBlocks.add(new BeepConfigCommand(BeepConfigType.BEEP)); + EnumSet deliveryTypeWithBeep = EnumSet.of(deliveryTypeList.remove(deliveryTypeList.size() - 1)); + EnumSet deliveryTypesWithoutBeep = EnumSet.copyOf(deliveryTypeList); + + messageBlocks.add(new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.NO_BEEP, deliveryTypesWithoutBeep)); + messageBlocks.add(new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.BEEP, deliveryTypeWithBeep)); + } else { + messageBlocks.add(new CancelDeliveryCommand(podState.getCurrentNonce(), + acknowledgementBeep && deliveryTypes.size() == 1 ? BeepType.BEEP : BeepType.NO_BEEP, deliveryTypes)); } return communicationService.exchangeMessages(StatusResponse.class, podState, diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/InsertCannulaService.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/InsertCannulaService.java index 4a6c6a4093..43248af7d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/InsertCannulaService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/action/service/InsertCannulaService.java @@ -31,7 +31,7 @@ public class InsertCannulaService { DateTime endOfServiceTime = podState.getActivatedAt().plus(OmnipodConst.SERVICE_DURATION); Duration timeUntilExpirationAdvisoryAlarm = new Duration(DateTime.now(), - endOfServiceTime.minus(OmnipodConst.END_OF_SERVICE_IMMINENT_WINDOW).minus(OmnipodConst.EXPIRATION_ADVISORY_WINDOW)); + endOfServiceTime.minus(OmnipodConst.EXPIRATION_ADVISORY_WINDOW)); Duration timeUntilShutdownImminentAlarm = new Duration(DateTime.now(), endOfServiceTime.minus(OmnipodConst.END_OF_SERVICE_IMMINENT_WINDOW)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java index 367008b5e7..dba478b0f6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/OmnipodConst.java @@ -45,9 +45,9 @@ public class OmnipodConst { public static final Duration AVERAGE_BOLUS_COMMAND_COMMUNICATION_DURATION = Duration.millis(1500); public static final Duration SERVICE_DURATION = Duration.standardHours(80); - public static final Duration EXPIRATION_ADVISORY_WINDOW = Duration.standardHours(2); + public static final Duration EXPIRATION_ADVISORY_WINDOW = Duration.standardHours(9); public static final Duration END_OF_SERVICE_IMMINENT_WINDOW = Duration.standardHours(1); - public static final Duration NOMINAL_POD_LIFE = SERVICE_DURATION.minus(END_OF_SERVICE_IMMINENT_WINDOW).minus(EXPIRATION_ADVISORY_WINDOW); + public static final Duration NOMINAL_POD_LIFE = Duration.standardHours(72); public static final double LOW_RESERVOIR_ALERT = 20.0; public static final double POD_PRIME_BOLUS_UNITS = 2.6;