From 665444ea9e780b543038a597e6e2316bb4b1df1e Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sat, 19 Jun 2021 16:12:41 +0200 Subject: [PATCH] fix command sending failure --- .../pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 8 ++++++-- .../dash/driver/OmnipodDashManagerImpl.kt | 17 +++++------------ .../dash/ui/DashPodManagementActivity.kt | 4 +++- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index cd67f57ace..2ee5e2acaf 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -189,7 +189,7 @@ class OmnipodDashPumpPlugin @Inject constructor( override fun setNewBasalProfile(profile: Profile): PumpEnactResult { if (!podStateManager.isActivationCompleted) { - return PumpEnactResult(injector).success(true).enacted(false) + return PumpEnactResult(injector).success(true).enacted(true) } val basalProgram = mapProfileToBasalProgram(profile) return executeProgrammingCommand( @@ -773,10 +773,14 @@ class OmnipodDashPumpPlugin @Inject constructor( } private fun deactivatePod(): PumpEnactResult { - return executeProgrammingCommand( + val ret = executeProgrammingCommand( historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), command = omnipodManager.deactivatePod().ignoreElements() ).toPumpEnactResult() + if (podStateManager.activeCommand != null) { + ret.success(false) + } + return ret } private fun handleTimeChange(): PumpEnactResult { diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index 8d131db1d5..78b778def9 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -166,7 +166,7 @@ class OmnipodDashManagerImpl @Inject constructor( .setUniqueId(podStateManager.uniqueId!!.toInt()) .setSequenceNumber(podStateManager.messageSequenceNumber) .setNonce(NONCE) - .setProgramReminder(ProgramReminder(atStart = hasBasalBeepEnabled, atEnd = hasBasalBeepEnabled, atInterval = 0)) + .setProgramReminder(ProgramReminder(atStart = hasBasalBeepEnabled, atEnd = false, atInterval = 0)) .setBasalProgram(basalProgram) .setCurrentTime(currentTime) .build(), @@ -436,18 +436,11 @@ class OmnipodDashManagerImpl @Inject constructor( beepEnabled: Boolean ): Observable { return Observable.defer { - val beepType = if (!beepEnabled) { + val beepType = if (!beepEnabled) BeepType.SILENT - } else { - when (deliveryType) { - StopDeliveryCommand.DeliveryType.ALL, StopDeliveryCommand.DeliveryType.BASAL -> - BeepType.FOUR_TIMES_BIP_BEEP - StopDeliveryCommand.DeliveryType.TEMP_BASAL -> - BeepType.LONG_SINGLE_BEEP - StopDeliveryCommand.DeliveryType.BOLUS -> - BeepType.LONG_SINGLE_BEEP - } - } + else + BeepType.LONG_SINGLE_BEEP + bleManager.sendCommand( StopDeliveryCommand.Builder() .setSequenceNumber(podStateManager.messageSequenceNumber) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt index 66e7fa3a62..a293e04b74 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodManagementActivity.kt @@ -14,6 +14,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.ui.wizard.activati import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.databinding.OmnipodDashPodManagementBinding import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ActivationProgress +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.activation.DashPodActivationWizardActivity import info.nightscout.androidaps.plugins.pump.omnipod.dash.ui.wizard.deactivation.DashPodDeactivationWizardActivity @@ -124,7 +125,8 @@ class DashPodManagementActivity : NoSplashAppCompatActivity() { binding.buttonActivatePod.isEnabled = podStateManager.activationProgress.isBefore(ActivationProgress.COMPLETED) binding.buttonDeactivatePod.isEnabled = - podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) + podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED) || + podStateManager.podStatus == PodStatus.ALARM if (podStateManager.activationProgress.isAtLeast(ActivationProgress.PHASE_1_COMPLETED)) { if (commandQueue.isCustomCommandInQueue(CommandPlayTestBeep::class.java)) {