fixes:
- read(and log) message on connect if there is RTS waiting - show yellow pod status on unconfirmed commands
This commit is contained in:
parent
b9af0c3f6f
commit
eb33e89ea7
2 changed files with 14 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue