From ebdc2aebe030490c6eeb59bae6e5701829978597 Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Mon, 15 Mar 2021 01:34:02 +0100 Subject: [PATCH] More WIP on Omnipod Dash Pod activation --- .../dash/driver/OmnipodDashManagerImpl.kt | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) 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 ecb847fb35..d050e82476 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 @@ -105,19 +105,16 @@ class OmnipodDashManagerImpl @Inject constructor( } private val observeVerifyCannulaInsertion: Observable - get() = Observable.defer { - observeSendGetPodStatusCommand() - .ignoreElements() // - .andThen( - Observable.defer { - if (podStateManager.podStatus == PodStatus.RUNNING_ABOVE_MIN_VOLUME) { - Observable.empty() - } else { - Observable.error(IllegalStateException("Unexpected Pod status")) - } - } - ) - } + get() = Observable.concat( + observeSendGetPodStatusCommand(), + Observable.defer { + if (podStateManager.podStatus == PodStatus.RUNNING_ABOVE_MIN_VOLUME) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status")) + } + } + ) private fun observeSendProgramAlertsCommand( alertConfigurations: List, @@ -153,19 +150,16 @@ class OmnipodDashManagerImpl @Inject constructor( } private val observeVerifyPrime: Observable - get() = Observable.defer { - observeSendGetPodStatusCommand() - .ignoreElements() // - .andThen( - Observable.defer { - if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) { - Observable.empty() - } else { - Observable.error(IllegalStateException("Unexpected Pod status: got ${podStateManager.podStatus}, expected CLUTCH_DRIVE_ENGAGED")) - } - } - ) - } + get() = Observable.concat( + observeSendGetPodStatusCommand(ResponseType.StatusResponseType.DEFAULT_STATUS_RESPONSE), + Observable.defer { + if (podStateManager.podStatus == PodStatus.CLUTCH_DRIVE_ENGAGED) { + Observable.empty() + } else { + Observable.error(IllegalStateException("Unexpected Pod status: got ${podStateManager.podStatus}, expected CLUTCH_DRIVE_ENGAGED")) + } + } + ) private val observeSendSetUniqueIdCommand: Observable get() = Observable.defer { @@ -196,6 +190,7 @@ class OmnipodDashManagerImpl @Inject constructor( return Observable.concat( observePodReadyForActivationPart1, observePairNewPod, + observeConnectToPod, // FIXME needed after disconnect; observePairNewPod does not connect in that case. observeActivationPart1Commands(lowReservoirAlertTrigger) ).doOnComplete(ActivationProgressUpdater(ActivationProgress.PHASE_1_COMPLETED)) // TODO these would be common for any observable returned in a public function in this class