diff --git a/pump/omnipod-common/src/main/res/values/strings.xml b/pump/omnipod-common/src/main/res/values/strings.xml
index 040757704d..d2ecea3ce0 100644
--- a/pump/omnipod-common/src/main/res/values/strings.xml
+++ b/pump/omnipod-common/src/main/res/values/strings.xml
@@ -8,7 +8,9 @@
AAPS.Omnipod.suspend_delivery_button_enabled
AAPS.Omnipod.time_change_enabled
AAPS.Omnipod.expiration_reminder_enabled
- AAPS.Omnipod.expiration_reminder_hours_before_shutdown
+ AAPS.Omnipod.expiration_reminder_hours_before_expiry
+ AAPS.Omnipod.expiration_alarm_enabled
+ AAPS.Omnipod.expiration_alarm_hours_before_shutdown
AAPS.Omnipod.low_reservoir_alert_enabled
AAPS.Omnipod.low_reservoir_alert_units
AAPS.Omnipod.automatically_acknowledge_alerts_enabled
@@ -129,7 +131,11 @@
Show Suspend Delivery button in Omnipod tab
DST/Time zone detection enabled
Expiration reminder enabled
- Hours before shutdown
+ When enabled the pod will beep when the specified time is reached
+ Reminder at hours before expiry (72 Hours)
+ Expiration alert enabled
+ When enabled the pod will beep when the specified time is reached and 1 hour before shutdown
+ Alert at hours before shutdown (80 Hours)
Low reservoir alert enabled
Number of units
Automatically silence Pod alerts
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
index 8f4e0fe4b9..dc3f00fe96 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt
@@ -22,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
+import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmed
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager
@@ -84,6 +85,7 @@ import java.time.Duration
import java.time.ZonedDateTime
import java.util.Date
import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.concurrent.thread
@@ -480,7 +482,9 @@ class OmnipodDashPumpPlugin @Inject constructor(
.subscribe(
{
if (it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled)) ||
- it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown)) ||
+ it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry)) ||
+ it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled)) ||
+ it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled)) ||
it.isChanged(rh.gs(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units))
) {
@@ -1102,16 +1106,22 @@ class OmnipodDashPumpPlugin @Inject constructor(
return when (customCommand) {
is CommandSilenceAlerts ->
silenceAlerts()
+
is CommandResumeDelivery ->
resumeDelivery()
+
is CommandDeactivatePod ->
deactivatePod()
+
is CommandHandleTimeChange ->
handleTimeChange()
+
is CommandUpdateAlertConfiguration ->
updateAlertConfiguration()
+
is CommandPlayTestBeep ->
playTestBeep()
+
is CommandDisableSuspendAlerts ->
disableSuspendAlerts()
@@ -1214,14 +1224,18 @@ class OmnipodDashPumpPlugin @Inject constructor(
private fun updateAlertConfiguration(): PumpEnactResult {
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
- val expirationHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 7)
+ val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
+ val expirationAlarmEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled, true)
+ val expirationAlarmHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown, 8)
val lowReservoirAlertEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_enabled, true)
val lowReservoirAlertUnits = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_low_reservoir_alert_units, 10)
when {
podStateManager.sameAlertSettings(
expirationReminderEnabled,
- expirationHours,
+ expirationReminderHours,
+ expirationAlarmEnabled,
+ expirationAlarmHours,
lowReservoirAlertEnabled,
lowReservoirAlertUnits
) -> {
@@ -1236,12 +1250,28 @@ class OmnipodDashPumpPlugin @Inject constructor(
}
val podLifeLeft = Duration.between(ZonedDateTime.now(), podStateManager.expiry)
- val expiryAlertDelay = podLifeLeft.minus(Duration.ofHours(expirationHours.toLong()))
- if (expiryAlertDelay.isNegative) {
+ val expiryReminderDelay = podLifeLeft.minus(Duration.ofHours(expirationReminderHours.toLong()))
+ if (expiryReminderDelay.isNegative) {
aapsLogger.warn(
LTag.PUMPBTCOMM,
- "updateAlertConfiguration negative " +
- "expiryAlertDuration=$expiryAlertDelay"
+ "updateAlertConfiguration negative expiryAlertDuration=$expiryReminderDelay"
+ )
+ PumpEnactResult(injector).success(false).enacted(false)
+ }
+ // expiry Alarm Delay, add 8 hours (grace period)
+ val expiryAlarmDelay = podLifeLeft.minus(Duration.ofHours(expirationAlarmHours.toLong())).plus(Duration.ofHours(8))
+ if (expiryAlarmDelay.isNegative) {
+ aapsLogger.warn(
+ LTag.PUMPBTCOMM,
+ "updateAlertConfiguration negative expiryAlarmDuration=$expiryAlarmDelay"
+ )
+ PumpEnactResult(injector).success(false).enacted(false)
+ }
+ val expiryImminentDelay = podLifeLeft.minus(Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)).plus(Duration.ofHours(8))
+ if (expiryImminentDelay.isNegative) {
+ aapsLogger.warn(
+ LTag.PUMPBTCOMM,
+ "updateAlertConfiguration negative expiryImminentDuration=$expiryImminentDelay"
)
PumpEnactResult(injector).success(false).enacted(false)
}
@@ -1261,18 +1291,43 @@ class OmnipodDashPumpPlugin @Inject constructor(
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
- expiryAlertDelay.toMinutes().toShort()
+ expiryReminderDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
+ ),
+ AlertConfiguration(
+ AlertType.EXPIRATION,
+ enabled = expirationAlarmEnabled,
+ durationInMinutes = TimeUnit.HOURS.toMinutes((expirationAlarmHours - 1).toLong()).toShort(),
+ autoOff = false,
+ AlertTrigger.TimerTrigger(
+ expiryAlarmDelay.toMinutes().toShort()
+ ),
+ BeepType.FOUR_TIMES_BIP_BEEP,
+ BeepRepetitionType.XXX3
+ ),
+ AlertConfiguration(
+ AlertType.EXPIRATION_IMMINENT,
+ enabled = expirationAlarmEnabled,
+ durationInMinutes = 0,
+ autoOff = false,
+ AlertTrigger.TimerTrigger(
+ expiryImminentDelay.toMinutes().toShort()
+ ),
+ BeepType.FOUR_TIMES_BIP_BEEP,
+ BeepRepetitionType.XXX3
)
)
+
return executeProgrammingCommand(
historyEntry = history.createRecord(OmnipodCommandType.CONFIGURE_ALERTS),
command = omnipodManager.programAlerts(alerts).ignoreElements(),
post = podStateManager.updateExpirationAlertSettings(
expirationReminderEnabled,
- expirationHours
+ expirationReminderHours,
+ expirationAlarmEnabled,
+ expirationAlarmHours
).andThen(
podStateManager.updateLowReservoirAlertSettings(
lowReservoirAlertEnabled,
@@ -1513,10 +1568,10 @@ class OmnipodDashPumpPlugin @Inject constructor(
// Cancel TBR running on Pump
return@defer observeNoActiveTempBasal()
.concatWith(podStateManager.updateActiveCommand()
- .map { handleCommandConfirmation(it) }
- .ignoreElement())
+ .map { handleCommandConfirmation(it) }
+ .ignoreElement())
}
-
+
return@defer Completable.complete()
}
@@ -1537,10 +1592,13 @@ class OmnipodDashPumpPlugin @Inject constructor(
return when (notificationType) {
Notification.OMNIPOD_TBR_ALERTS ->
sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_notification_uncertain_tbr_sound_enabled, true)
+
Notification.OMNIPOD_UNCERTAIN_SMB ->
sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_notification_uncertain_smb_sound_enabled, true)
+
Notification.OMNIPOD_POD_SUSPENDED ->
sp.getBoolean(R.string.key_omnipod_common_notification_delivery_suspended_sound_enabled, true)
+
else -> true
}
}
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt
index c08f20418f..c99e72a47a 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt
@@ -15,7 +15,7 @@ interface OmnipodDashManager {
fun activatePodPart1(lowReservoirAlertTrigger: AlertTrigger.ReservoirVolumeTrigger?): Observable
- fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?): Observable
+ fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?): Observable
fun getStatus(type: ResponseType.StatusResponseType): Observable
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt
index 8fd963dbba..b3080dd2b3 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt
@@ -23,11 +23,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
-import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.MAX_POD_LIFETIME
-import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS
-import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_DURATION
-import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS
+import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT
+import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_PULSE_BOLUS_UNITS
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder
@@ -161,9 +159,9 @@ class OmnipodDashManagerImpl @Inject constructor(
// TODO move somewhere else
val expectedResponseType = when (type) {
ResponseType.StatusResponseType.DEFAULT_STATUS_RESPONSE -> DefaultStatusResponse::class
- ResponseType.StatusResponseType.ALARM_STATUS -> AlarmStatusResponse::class
+ ResponseType.StatusResponseType.ALARM_STATUS -> AlarmStatusResponse::class
- else -> return Observable.error(UnsupportedOperationException("No response type to class mapping for ${type.name}"))
+ else -> return Observable.error(UnsupportedOperationException("No response type to class mapping for ${type.name}"))
}
return Observable.defer {
@@ -368,19 +366,19 @@ class OmnipodDashManagerImpl @Inject constructor(
return observables.reversed()
}
- override fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?):
+ override fun activatePodPart2(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?):
Observable {
return Observable.concat(
observePodReadyForActivationPart2,
observeConnectToPod,
- observeActivationPart2Commands(basalProgram, userConfiguredExpirationHours)
+ observeActivationPart2Commands(basalProgram, userConfiguredExpirationReminderHours, userConfiguredExpirationAlarmHours)
).doOnComplete(ActivationProgressUpdater(ActivationProgress.COMPLETED))
.interceptPodEvents()
}
- private fun observeActivationPart2Commands(basalProgram: BasalProgram, userConfiguredExpirationHours: Long?):
+ private fun observeActivationPart2Commands(basalProgram: BasalProgram, userConfiguredExpirationReminderHours: Long?, userConfiguredExpirationAlarmHours: Long?):
Observable {
- val observables = createActivationPart2Observables(basalProgram, userConfiguredExpirationHours)
+ val observables = createActivationPart2Observables(basalProgram, userConfiguredExpirationReminderHours, userConfiguredExpirationAlarmHours)
return if (observables.isEmpty()) {
Observable.empty()
@@ -391,7 +389,8 @@ class OmnipodDashManagerImpl @Inject constructor(
private fun createActivationPart2Observables(
basalProgram: BasalProgram,
- userConfiguredExpirationHours: Long?
+ userConfiguredExpirationReminderHours: Long?,
+ userConfiguredExpirationAlarmHours: Long?
):
List> {
val observables = ArrayList>()
@@ -422,48 +421,60 @@ class OmnipodDashManagerImpl @Inject constructor(
if (podStateManager.activationProgress.isBefore(ActivationProgress.UPDATED_EXPIRATION_ALERTS)) {
val podLifeLeft = Duration.between(ZonedDateTime.now(), podStateManager.expiry)
+ val expirationAlarmEnabled = userConfiguredExpirationAlarmHours != null && userConfiguredExpirationAlarmHours > 0
+ val expirationAlarmDelay = podLifeLeft.minus(
+ Duration.ofHours(userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT)
+ ).plus(Duration.ofHours(8)) // Add 8 hours for grace period
+
+ val expirationImminentDelay = podLifeLeft.minus(
+ Duration.ofHours(POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING)
+ ).plus(Duration.ofHours(8)) // Add 8 hours for grace period
+
val alerts = mutableListOf(
AlertConfiguration(
AlertType.EXPIRATION,
- enabled = true,
- durationInMinutes = TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS_DURATION).toShort(),
+ enabled = expirationAlarmEnabled,
+ durationInMinutes = (TimeUnit.HOURS.toMinutes(
+ userConfiguredExpirationAlarmHours ?: POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT
+ ) - 60).toShort(),
autoOff = false,
AlertTrigger.TimerTrigger(
- TimeUnit.HOURS.toMinutes(POD_EXPIRATION_ALERT_HOURS).toShort()
- ), // FIXME use activation time
+ expirationAlarmDelay.toMinutes().toShort()
+ ),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.XXX3
),
AlertConfiguration(
AlertType.EXPIRATION_IMMINENT,
- enabled = true,
+ enabled = expirationAlarmEnabled,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
- TimeUnit.HOURS.toMinutes(POD_EXPIRATION_IMMINENT_ALERT_HOURS).toShort()
- ), // FIXME use activation time
+ expirationImminentDelay.toMinutes().toShort()
+ ),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.XXX4
)
)
- val userExpiryAlertDelay = podLifeLeft.minus(
- Duration.ofHours(userConfiguredExpirationHours ?: MAX_POD_LIFETIME.toHours() + 1)
+ val userExpiryReminderEnabled = userConfiguredExpirationReminderHours != null && userConfiguredExpirationReminderHours > 0
+ val userExpiryReminderDelay = podLifeLeft.minus(
+ Duration.ofHours(userConfiguredExpirationReminderHours ?: MAX_POD_LIFETIME.toHours() + 1)
)
- if (userExpiryAlertDelay.isNegative) {
+ if (userExpiryReminderDelay.isNegative) {
logger.warn(
LTag.PUMPBTCOMM,
"createActivationPart2Observables negative " +
- "expiryAlertDuration=$userExpiryAlertDelay"
+ "expiryAlertDuration=$userExpiryReminderDelay"
)
} else {
alerts.add(
AlertConfiguration(
AlertType.USER_SET_EXPIRATION,
- enabled = true,
+ enabled = userExpiryReminderEnabled,
durationInMinutes = 0,
autoOff = false,
AlertTrigger.TimerTrigger(
- userExpiryAlertDelay.toMinutes().toShort()
+ userExpiryReminderDelay.toMinutes().toShort()
),
BeepType.FOUR_TIMES_BIP_BEEP,
BeepRepetitionType.EVERY_MINUTE_AND_EVERY_15_MIN
@@ -693,16 +704,16 @@ class OmnipodDashManagerImpl @Inject constructor(
logger.debug(LTag.PUMP, "Intercepted PodEvent in OmnipodDashManagerImpl: ${event.javaClass.simpleName}")
when (event) {
- is PodEvent.AlreadyConnected -> {
+ is PodEvent.AlreadyConnected -> {
}
- is PodEvent.BluetoothConnected -> {
+ is PodEvent.BluetoothConnected -> {
}
- is PodEvent.Connected -> {
+ is PodEvent.Connected -> {
}
- is PodEvent.CommandSent -> {
+ is PodEvent.CommandSent -> {
logger.debug(LTag.PUMP, "Command sent: ${event.command.commandType}")
podStateManager.activeCommand?.let {
if (it.sequence == event.command.sequenceNumber) {
@@ -721,16 +732,16 @@ class OmnipodDashManagerImpl @Inject constructor(
podStateManager.increaseMessageSequenceNumber()
}
- is PodEvent.ResponseReceived -> {
+ is PodEvent.ResponseReceived -> {
podStateManager.increaseMessageSequenceNumber()
handleResponse(event.response)
}
- is PodEvent.Paired -> {
+ is PodEvent.Paired -> {
podStateManager.uniqueId = event.uniqueId.toLong()
}
- else -> {
+ else -> {
// Do nothing
}
}
@@ -738,11 +749,11 @@ class OmnipodDashManagerImpl @Inject constructor(
private fun handleResponse(response: Response) {
when (response) {
- is VersionResponse -> {
+ is VersionResponse -> {
podStateManager.updateFromVersionResponse(response)
}
- is SetUniqueIdResponse -> {
+ is SetUniqueIdResponse -> {
podStateManager.updateFromSetUniqueIdResponse(response)
}
@@ -750,7 +761,7 @@ class OmnipodDashManagerImpl @Inject constructor(
podStateManager.updateFromDefaultStatusResponse(response)
}
- is AlarmStatusResponse -> {
+ is AlarmStatusResponse -> {
podStateManager.updateFromAlarmStatusResponse(response)
}
}
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt
index 4a2124aace..cb406af20c 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/definition/PodConstants.kt
@@ -6,12 +6,11 @@ class PodConstants {
companion object {
val MAX_POD_LIFETIME: Duration = Duration.ofHours(80)
- // Expiration alert time in minutes since activation and duration in minutes
- const val POD_EXPIRATION_ALERT_HOURS = 72L
- const val POD_EXPIRATION_ALERT_HOURS_DURATION = 7L
+ // Expiration alert time in hours before lifetime end
+ const val POD_EXPIRATION_ALERT_HOURS_REMAINING_DEFAULT = 7L
- // Expiration eminent alert time in minutes since activation
- const val POD_EXPIRATION_IMMINENT_ALERT_HOURS = 79L
+ // Imminent expiration alert time in hours before lifetime end
+ const val POD_EXPIRATION_IMMINENT_ALERT_HOURS_REMAINING = 1L
// Bolus & Priming units
const val POD_PULSE_BOLUS_UNITS = 0.05
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
index 05efe00d2a..36b66c433b 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt
@@ -112,8 +112,20 @@ interface OmnipodDashPodStateManager {
- after getPodStatus was successful(we have an up-to-date podStatus)
*/
fun recoverActivationFromPodStatus(): String?
- fun sameAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int, lowReservoirAlertEnabled: Boolean, lowReservoirAlertUnits: Int): Boolean
- fun updateExpirationAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int): Completable
+ fun sameAlertSettings(
+ expirationReminderEnabled: Boolean,
+ expirationReminderHours: Int,
+ expirationAlarmEnabled: Boolean,
+ expirationAlarmHours: Int,
+ lowReservoirAlertEnabled: Boolean,
+ lowReservoirAlertUnits: Int
+ ): Boolean
+ fun updateExpirationAlertSettings(
+ expirationReminderEnabled: Boolean,
+ expirationReminderHours: Int,
+ expirationAlarmEnabled: Boolean,
+ expirationAlarmHours: Int
+ ): Completable
fun updateLowReservoirAlertSettings(lowReservoirAlertEnabled: Boolean, lowReservoirAlertUnits: Int): Completable
data class ActiveCommand(
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
index 9eef681ae6..6b58c193bc 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt
@@ -415,19 +415,25 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override fun recoverActivationFromPodStatus(): String? {
val newActivationProgress = when (podState.podStatus) {
- PodStatus.FILLED ->
+ PodStatus.FILLED ->
ActivationProgress.NOT_STARTED
- PodStatus.UID_SET ->
+
+ PodStatus.UID_SET ->
ActivationProgress.SET_UNIQUE_ID
- PodStatus.ENGAGING_CLUTCH_DRIVE, PodStatus.PRIMING ->
+
+ PodStatus.ENGAGING_CLUTCH_DRIVE, PodStatus.PRIMING ->
return "Busy"
- PodStatus.CLUTCH_DRIVE_ENGAGED ->
+
+ PodStatus.CLUTCH_DRIVE_ENGAGED ->
ActivationProgress.PRIME_COMPLETED
- PodStatus.BASAL_PROGRAM_SET ->
+
+ PodStatus.BASAL_PROGRAM_SET ->
ActivationProgress.PROGRAMMED_BASAL
+
PodStatus.RUNNING_ABOVE_MIN_VOLUME, PodStatus.RUNNING_BELOW_MIN_VOLUME ->
ActivationProgress.CANNULA_INSERTED
- else ->
+
+ else ->
null
}
newActivationProgress?.let {
@@ -447,7 +453,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
val cmdConfirmation = getCommandConfirmationFromState()
logger.info(LTag.PUMPCOMM, "Update active command with confirmation: $cmdConfirmation")
when (cmdConfirmation) {
- CommandSendingFailure -> {
+ CommandSendingFailure -> {
podState.activeCommand = null
source.onError(
activeCommand.sendError
@@ -463,7 +469,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
source.onComplete()
}
- CommandConfirmationDenied -> {
+ CommandConfirmationDenied -> {
podState.activeCommand = null
source.onSuccess(CommandConfirmed(activeCommand, false))
}
@@ -474,7 +480,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
source.onSuccess(CommandConfirmed(activeCommand, true))
}
- NoActiveCommand -> {
+ NoActiveCommand -> {
source.onComplete()
}
}
@@ -482,20 +488,30 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
override fun sameAlertSettings(
expirationReminderEnabled: Boolean,
- expirationHours: Int,
+ expirationReminderHours: Int,
+ expirationAlarmEnabled: Boolean,
+ expirationAlarmHours: Int,
lowReservoirAlertEnabled: Boolean,
lowReservoirAlertUnits: Int
): Boolean {
return podState.expirationReminderEnabled == expirationReminderEnabled &&
- podState.expirationHours == expirationHours &&
+ podState.expirationReminderHours == expirationReminderHours &&
+ podState.expirationAlarmEnabled == expirationAlarmEnabled &&
+ podState.expirationAlarmHours == expirationAlarmHours &&
podState.lowReservoirAlertEnabled == lowReservoirAlertEnabled &&
podState.lowReservoirAlertUnits == lowReservoirAlertUnits
}
- override fun updateExpirationAlertSettings(expirationReminderEnabled: Boolean, expirationHours: Int):
- Completable = Completable.defer {
+ override fun updateExpirationAlertSettings(
+ expirationReminderEnabled: Boolean,
+ expirationReminderHours: Int,
+ expirationAlarmEnabled: Boolean,
+ expirationAlarmHours: Int
+ ): Completable = Completable.defer {
podState.expirationReminderEnabled = expirationReminderEnabled
- podState.expirationHours = expirationHours
+ podState.expirationReminderHours = expirationReminderHours
+ podState.expirationAlarmEnabled = expirationAlarmEnabled
+ podState.expirationAlarmHours = expirationAlarmHours
Completable.complete()
}
@@ -520,15 +536,18 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
createdRealtime <= podState.lastStatusResponseReceived &&
sequence == podState.sequenceNumberOfLastProgrammingCommand ->
CommandConfirmationSuccess
+
createdRealtime <= podState.lastStatusResponseReceived &&
sequence != podState.sequenceNumberOfLastProgrammingCommand ->
CommandConfirmationDenied
// no response received after this point
- createdRealtime <= sentRealtime ->
+ createdRealtime <= sentRealtime ->
CommandSendingNotConfirmed
- createdRealtime > sentRealtime ->
+
+ createdRealtime > sentRealtime ->
CommandSendingFailure
- else -> // this can't happen, see the previous two conditions
+
+ else -> // this can't happen, see the previous two conditions
NoActiveCommand
}
} ?: NoActiveCommand
@@ -555,7 +574,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
podState.activeCommand = newCommand
}
- CommandSendingNotConfirmed -> {
+ CommandSendingNotConfirmed -> {
val now = SystemClock.elapsedRealtime()
val newCommand = podState.activeCommand?.copy(
createdRealtime = now,
@@ -565,7 +584,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
podState.lastStatusResponseReceived = 0
}
- CommandSendingFailure, NoActiveCommand -> {
+ CommandSendingFailure, NoActiveCommand -> {
podState.activeCommand = null
podState.lastStatusResponseReceived = 0
}
@@ -745,7 +764,9 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
var secondPrimeBolusVolume: Short? = null,
var expirationReminderEnabled: Boolean? = null,
- var expirationHours: Int? = null,
+ var expirationReminderHours: Int? = null,
+ var expirationAlarmEnabled: Boolean? = null,
+ var expirationAlarmHours: Int? = null,
var lowReservoirAlertEnabled: Boolean? = null,
var lowReservoirAlertUnits: Int? = null,
diff --git a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt
index 70c7aba9fd..18c4767350 100644
--- a/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt
+++ b/pump/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/wizard/activation/viewmodel/action/DashInsertCannulaViewModel.kt
@@ -67,16 +67,24 @@ class DashInsertCannulaViewModel @Inject constructor(
basalProgram
)
val expirationReminderEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_enabled, true)
- val expirationHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_shutdown, 9)
+ val expirationReminderHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_reminder_hours_before_expiry, 9)
- val expirationHoursBeforeShutdown = if (expirationReminderEnabled)
- expirationHours.toLong()
+ val expirationReminderHoursBeforeShutdown = if (expirationReminderEnabled)
+ expirationReminderHours.toLong()
else
null
- super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown)
+ val expirationAlarmEnabled = sp.getBoolean(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_enabled, true)
+ val expirationAlarmHours = sp.getInt(info.nightscout.androidaps.plugins.pump.omnipod.common.R.string.key_omnipod_common_expiration_alarm_hours_before_shutdown, 8)
+
+ val expirationAlarmHoursBeforeShutdown = if (expirationAlarmEnabled)
+ expirationAlarmHours.toLong()
+ else
+ null
+
+ super.disposable += omnipodManager.activatePodPart2(basalProgram, expirationReminderHoursBeforeShutdown, expirationAlarmHoursBeforeShutdown)
.ignoreElements()
- .andThen(podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationHours))
+ .andThen(podStateManager.updateExpirationAlertSettings(expirationReminderEnabled, expirationReminderHours, expirationAlarmEnabled, expirationAlarmHours))
.andThen(
history.createRecord(
OmnipodCommandType.INSERT_CANNULA,
diff --git a/pump/omnipod-dash/src/main/res/xml/omnipod_dash_preferences.xml b/pump/omnipod-dash/src/main/res/xml/omnipod_dash_preferences.xml
index b32f397967..cf0ae782a8 100644
--- a/pump/omnipod-dash/src/main/res/xml/omnipod_dash_preferences.xml
+++ b/pump/omnipod-dash/src/main/res/xml/omnipod_dash_preferences.xml
@@ -37,17 +37,35 @@
+ android:title="@string/omnipod_common_preferences_expiration_reminder_enabled"
+ android:summary="@string/omnipod_common_preferences_expiration_reminder_enabled_summary" />
+
+
+
+