remove the active command if we get an error sending it

This commit is contained in:
Andrei Vereha 2021-04-21 22:52:22 +02:00
parent 3a2fa6d04f
commit 20560f2a4e
3 changed files with 7 additions and 0 deletions

View file

@ -466,6 +466,7 @@ class OmnipodDashPumpPlugin @Inject constructor(
}, },
onError = { throwable -> onError = { throwable ->
aapsLogger.error(LTag.PUMP, "Error executing command", throwable) aapsLogger.error(LTag.PUMP, "Error executing command", throwable)
podStateManager.resetActiveCommand()
source.onSuccess( source.onSuccess(
PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message) PumpEnactResult(injector).success(false).enacted(false).comment(throwable.message)
) )

View file

@ -68,6 +68,7 @@ interface OmnipodDashPodStateManager {
fun createActiveCommand(historyId: String): Completable fun createActiveCommand(historyId: String): Completable
fun updateActiveCommand(): Maybe<PodEvent> fun updateActiveCommand(): Maybe<PodEvent>
fun resetActiveCommand()
data class ActiveCommand( data class ActiveCommand(
val sequence: Short, val sequence: Short,

View file

@ -202,6 +202,11 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
} }
} }
@Synchronized
override fun resetActiveCommand() {
podState.activeCommand = null
}
@Synchronized @Synchronized
override fun updateActiveCommand() = Maybe.create<PodEvent> { source -> override fun updateActiveCommand() = Maybe.create<PodEvent> { source ->
podState.activeCommand?.run { podState.activeCommand?.run {