- read(and log) message on connect if there is RTS waiting
 - show yellow pod status on unconfirmed commands
This commit is contained in:
Andrei Vereha 2021-07-17 12:09:15 +02:00
parent b9af0c3f6f
commit eb33e89ea7
2 changed files with 14 additions and 10 deletions
omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash

View file

@ -37,7 +37,7 @@ class MessageIO(
fun sendMessage(msg: MessagePacket): MessageSendResult { fun sendMessage(msg: MessagePacket): MessageSendResult {
val foundRTS = cmdBleIO.flushIncomingQueue() val foundRTS = cmdBleIO.flushIncomingQueue()
if (foundRTS) { if (foundRTS) {
val msg = receiveMessage() val msg = receiveMessage(false)
aapsLogger.warn(LTag.PUMPBTCOMM, "sendMessage received message=$msg") aapsLogger.warn(LTag.PUMPBTCOMM, "sendMessage received message=$msg")
throw IllegalStateException("Received message while trying to send") throw IllegalStateException("Received message while trying to send")
} }
@ -90,11 +90,13 @@ class MessageIO(
} }
@Suppress("ReturnCount") @Suppress("ReturnCount")
fun receiveMessage(): MessagePacket? { fun receiveMessage(readRTS: Boolean = true): MessagePacket? {
val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS) if (readRTS) {
if (expectRTS !is BleConfirmSuccess) { val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS)
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS") if (expectRTS !is BleConfirmSuccess) {
return null aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS")
return null
}
} }
val sendResult = cmdBleIO.sendAndConfirmPacket(BleCommandCTS.data) val sendResult = cmdBleIO.sendAndConfirmPacket(BleCommandCTS.data)

View file

@ -432,12 +432,14 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
} }
val podStatusColor = val podStatusColor = when {
if (!podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended) { !podStateManager.isActivationCompleted || podStateManager.isPodKaput || podStateManager.isSuspended ->
Color.RED Color.RED
} else { podStateManager.activeCommand != null ->
Color.YELLOW
else ->
Color.WHITE Color.WHITE
} }
podInfoBinding.podStatus.setTextColor(podStatusColor) podInfoBinding.podStatus.setTextColor(podStatusColor)
} }