diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt index 2e1dbaa150..a4e403cd42 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt @@ -899,6 +899,7 @@ class Pump( */ suspend fun connect(maxNumAttempts: Int? = DEFAULT_MAX_NUM_REGULAR_CONNECT_ATTEMPTS) { check(stateFlow.value == State.Disconnected) { "Attempted to connect to pump in the ${stateFlow.value} state" } + check((maxNumAttempts == null) || (maxNumAttempts > 0)) val actualMaxNumAttempts = maxNumAttempts ?: Int.MAX_VALUE