From e9f75f4f9bfd00bb22c9f0fc9c6b315f4394d78b Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Sat, 26 Nov 2022 23:07:10 +0100 Subject: [PATCH] combov2: Report error when invalid PUMP_SUSPEND TBR is received Signed-off-by: Carlos Rafael Giani --- .../nightscout/pump/combov2/ComboV2Plugin.kt | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pump/combov2/src/main/kotlin/info/nightscout/pump/combov2/ComboV2Plugin.kt b/pump/combov2/src/main/kotlin/info/nightscout/pump/combov2/ComboV2Plugin.kt index 1d08a68795..94de50d926 100644 --- a/pump/combov2/src/main/kotlin/info/nightscout/pump/combov2/ComboV2Plugin.kt +++ b/pump/combov2/src/main/kotlin/info/nightscout/pump/combov2/ComboV2Plugin.kt @@ -974,8 +974,19 @@ class ComboV2Plugin @Inject constructor ( val cctlTbrType = when (tbrType) { PumpSync.TemporaryBasalType.NORMAL -> ComboCtlTbr.Type.NORMAL PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND -> ComboCtlTbr.Type.EMULATED_COMBO_STOP - PumpSync.TemporaryBasalType.PUMP_SUSPEND -> ComboCtlTbr.Type.COMBO_STOPPED // TODO: Can this happen? It is currently not allowed by ComboCtlPump.setTbr() PumpSync.TemporaryBasalType.SUPERBOLUS -> ComboCtlTbr.Type.SUPERBOLUS + PumpSync.TemporaryBasalType.PUMP_SUSPEND -> { + aapsLogger.error( + LTag.PUMP, + "PUMP_SUSPEND TBR type produced by AAPS for the TBR initiation even though this is supposed to only be produced by pump drivers" + ) + pumpEnactResult.apply { + success = false + enacted = false + comment = rh.gs(R.string.error) + } + return pumpEnactResult + } } setTbrInternal(limitedPercentage, durationInMinutes, cctlTbrType, force100Percent = false, pumpEnactResult) @@ -994,8 +1005,19 @@ class ComboV2Plugin @Inject constructor ( val cctlTbrType = when (tbrType) { PumpSync.TemporaryBasalType.NORMAL -> ComboCtlTbr.Type.NORMAL PumpSync.TemporaryBasalType.EMULATED_PUMP_SUSPEND -> ComboCtlTbr.Type.EMULATED_COMBO_STOP - PumpSync.TemporaryBasalType.PUMP_SUSPEND -> ComboCtlTbr.Type.COMBO_STOPPED // TODO: Can this happen? It is currently not allowed by ComboCtlPump.setTbr() PumpSync.TemporaryBasalType.SUPERBOLUS -> ComboCtlTbr.Type.SUPERBOLUS + PumpSync.TemporaryBasalType.PUMP_SUSPEND -> { + aapsLogger.error( + LTag.PUMP, + "PUMP_SUSPEND TBR type produced by AAPS for the TBR initiation even though this is supposed to only be produced by pump drivers" + ) + pumpEnactResult.apply { + success = false + enacted = false + comment = rh.gs(R.string.error) + } + return pumpEnactResult + } } setTbrInternal(limitedPercentage, durationInMinutes, cctlTbrType, force100Percent = false, pumpEnactResult)