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 {
|
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,12 +90,14 @@ class MessageIO(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("ReturnCount")
|
@Suppress("ReturnCount")
|
||||||
fun receiveMessage(): MessagePacket? {
|
fun receiveMessage(readRTS: Boolean = true): MessagePacket? {
|
||||||
|
if (readRTS) {
|
||||||
val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS)
|
val expectRTS = cmdBleIO.expectCommandType(BleCommandRTS, MESSAGE_READ_TIMEOUT_MS)
|
||||||
if (expectRTS !is BleConfirmSuccess) {
|
if (expectRTS !is BleConfirmSuccess) {
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS")
|
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading RTS: $expectRTS")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val sendResult = cmdBleIO.sendAndConfirmPacket(BleCommandCTS.data)
|
val sendResult = cmdBleIO.sendAndConfirmPacket(BleCommandCTS.data)
|
||||||
if (sendResult !is BleSendSuccess) {
|
if (sendResult !is BleSendSuccess) {
|
||||||
|
|
|
@ -432,10 +432,12 @@ 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)
|
||||||
|
|
Loading…
Reference in a new issue