From eb33e89ea75ed0fc95a9e9936f18210eb917019b Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sat, 17 Jul 2021 12:09:15 +0200 Subject: [PATCH] fixes: - read(and log) message on connect if there is RTS waiting - show yellow pod status on unconfirmed commands --- .../omnipod/dash/driver/comm/message/MessageIO.kt | 14 ++++++++------ .../omnipod/dash/ui/OmnipodDashOverviewFragment.kt | 10 ++++++---- 2 files changed, 14 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 2394ae14e2..0aa3033894 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 @@ -37,7 +37,7 @@ class MessageIO( fun sendMessage(msg: MessagePacket): MessageSendResult { val foundRTS = cmdBleIO.flushIncomingQueue() if (foundRTS) { - val msg = receiveMessage() + val msg = receiveMessage(false) aapsLogger.warn(LTag.PUMPBTCOMM, "sendMessage received message=$msg") throw IllegalStateException("Received message while trying to send") } @@ -90,11 +90,13 @@ class MessageIO( } @Suppress("ReturnCount") - fun receiveMessage(): MessagePacket? { - val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS) - if (expectRTS !is BleConfirmSuccess) { - aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS") - return null + fun receiveMessage(readRTS: Boolean = true): MessagePacket? { + if (readRTS) { + val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS) + if (expectRTS !is BleConfirmSuccess) { + aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS") + return null + } } val sendResult = cmdBleIO.sendAndConfirmPacket(BleCommandCTS.data) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index ea37bf5aeb..97f70338a5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -432,12 +432,14 @@ class OmnipodDashOverviewFragment : DaggerFragment() { } } - val podStatusColor = - if (!podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended) { + val podStatusColor = when { + !podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended -> Color.RED - } else { + podStateManager.activeCommand != null -> + Color.YELLOW + else -> Color.WHITE - } + } podInfoBinding.podStatus.setTextColor(podStatusColor) }