From 40a56d11ee3705787184df6d187ccc50fd237aa7 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 14 Sep 2021 20:01:21 +0200 Subject: [PATCH] bufix for ALARM_ILLEGAL_PUMP_STATE --- .../pump/omnipod/dash/driver/comm/message/MessageIO.kt | 6 +++--- .../pump/omnipod/dash/driver/comm/session/Session.kt | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt index 8c20958cf3..7292efa785 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt @@ -177,10 +177,10 @@ class MessageIO( } BleCommandSuccess -> { - if (index != packets.size) - MessageSendErrorSending("Received SUCCESS before sending all the data. $index") - else + if (index == packets.size-1) MessageSendSuccess + else + MessageSendErrorSending("Received SUCCESS before sending all the data. $index") } else -> diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt index 4c4531689a..5ae607b1b5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Session.kt @@ -37,7 +37,6 @@ class Session( aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command: ${cmd.encoded.toHex()} in packet $cmd") val msg = getCmdMessage(cmd) - var possiblyUnconfirmedCommand = false for (i in 0..MAX_TRIES) { aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command(wrapped): ${msg.payload.toHex()}") @@ -46,8 +45,8 @@ class Session( return CommandSendSuccess is MessageSendErrorConfirming -> { - possiblyUnconfirmedCommand = true aapsLogger.debug(LTag.PUMPBTCOMM, "Error confirming command: $sendResult") + return CommandSendErrorConfirming(sendResult.msg) } is MessageSendErrorSending -> @@ -55,11 +54,8 @@ class Session( } } - val errMsg = "Maximum number of tries reached. Could not send command\"" - return if (possiblyUnconfirmedCommand) - CommandSendErrorConfirming(errMsg) - else - CommandSendErrorSending(errMsg) + val errMsg = "Maximum number of tries reached. Could not send command" + return CommandSendErrorSending(errMsg) } @Suppress("ReturnCount")