From 20560f2a4edda665dbaea12f63366de6e0816856 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Wed, 21 Apr 2021 22:52:22 +0200 Subject: [PATCH] remove the active command if we get an error sending it --- .../plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 1 + .../dash/driver/pod/state/OmnipodDashPodStateManager.kt | 1 + .../dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt | 5 +++++ 3 files changed, 7 insertions(+) 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 a1b9d55de7..b063b058d5 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 @@ -466,6 +466,7 @@ class OmnipodDashPumpPlugin @Inject constructor( }, onError = { throwable -> aapsLogger.error(LTag.PUMP, "Error executing command", throwable) + podStateManager.resetActiveCommand() source.onSuccess( PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message) ) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt index 67bcac8209..e34c508657 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManager.kt @@ -68,6 +68,7 @@ interface OmnipodDashPodStateManager { fun createActiveCommand(historyId: String): Completable fun updateActiveCommand(): Maybe + fun resetActiveCommand() data class ActiveCommand( val sequence: Short, diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index a3f1ece6d1..4f4bdbc098 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -202,6 +202,11 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( } } + @Synchronized + override fun resetActiveCommand() { + podState.activeCommand = null + } + @Synchronized override fun updateActiveCommand() = Maybe.create { source -> podState.activeCommand?.run {