From c68491ba78447b193e833e322dc8c546ec430f1d Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 31 Oct 2021 00:22:50 +0200 Subject: [PATCH] fix deactivation --- .../omnipod/dash/OmnipodDashPumpPlugin.kt | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 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 4db2aa2bc1..f320cc0150 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 @@ -310,8 +310,8 @@ class OmnipodDashPumpPlugin @Inject constructor( ) private fun checkPodKaput(): Completable = Completable.defer { - val tbr = pumpSync.expectedPumpState().temporaryBasal if (podStateManager.isPodKaput) { + val tbr = pumpSync.expectedPumpState().temporaryBasal if (tbr == null || tbr.rate != 0.0) { pumpSync.syncTemporaryBasalWithPumpId( timestamp = System.currentTimeMillis(), @@ -340,20 +340,23 @@ class OmnipodDashPumpPlugin @Inject constructor( aapsLogger.info(LTag.PUMP, "syncBolusWithPumpId on CANCEL_BOLUS returned: $sync") } } - showNotification( - Notification.OMNIPOD_POD_FAULT, - podStateManager.alarmType.toString(), - Notification.URGENT, - R.raw.boluserror - ) - if (!podStateManager.alarmSynced) { - pumpSync.insertAnnouncement( - error = podStateManager.alarmType?.toString() ?: "Unknown pod failure", - pumpId = Random.Default.nextLong(), - pumpType = PumpType.OMNIPOD_DASH, - pumpSerial = serialNumber() + + podStateManager.alarmType?.let { + showNotification( + Notification.OMNIPOD_POD_FAULT, + it.toString(), + Notification.URGENT, + R.raw.boluserror ) - podStateManager.alarmSynced = true + if (!podStateManager.alarmSynced) { + pumpSync.insertAnnouncement( + error = it.toString(), + pumpId = Random.Default.nextLong(), + pumpType = PumpType.OMNIPOD_DASH, + pumpSerial = serialNumber() + ) + podStateManager.alarmSynced = true + } } } Completable.complete() @@ -1165,14 +1168,14 @@ class OmnipodDashPumpPlugin @Inject constructor( val ret = executeProgrammingCommand( historyEntry = history.createRecord(OmnipodCommandType.DEACTIVATE_POD), command = omnipodManager.deactivatePod().ignoreElements(), - checkNoActiveCommand = false, - post = createFakeTBRWhenNoActivePod(), + checkNoActiveCommand = false ).doOnComplete { if (podStateManager.activeCommand != null) { success = false + } else { + podStateManager.reset() + rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) } - podStateManager.reset() - rxBus.send(EventDismissNotification(Notification.OMNIPOD_POD_FAULT)) }.toPumpEnactResult() if (!success) { ret.success(false)