Merge pull request #116 from 0pen-dash/avereha/unconfirmed

bugfix: ALARM_ILLEGAL_PUMP_STATE
This commit is contained in:
Andrei Vereha 2021-09-14 20:19:15 +02:00 committed by GitHub
commit 829f5fec6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View file

@ -177,10 +177,10 @@ class MessageIO(
} }
BleCommandSuccess -> { BleCommandSuccess -> {
if (index != packets.size) if (index == packets.size-1)
MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
else
MessageSendSuccess MessageSendSuccess
else
MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
} }
else -> else ->

View file

@ -37,7 +37,6 @@ class Session(
aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command: ${cmd.encoded.toHex()} in packet $cmd") aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command: ${cmd.encoded.toHex()} in packet $cmd")
val msg = getCmdMessage(cmd) val msg = getCmdMessage(cmd)
var possiblyUnconfirmedCommand = false
for (i in 0..MAX_TRIES) { for (i in 0..MAX_TRIES) {
aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command(wrapped): ${msg.payload.toHex()}") aapsLogger.debug(LTag.PUMPBTCOMM, "Sending command(wrapped): ${msg.payload.toHex()}")
@ -46,8 +45,8 @@ class Session(
return CommandSendSuccess return CommandSendSuccess
is MessageSendErrorConfirming -> { is MessageSendErrorConfirming -> {
possiblyUnconfirmedCommand = true
aapsLogger.debug(LTag.PUMPBTCOMM, "Error confirming command: $sendResult") aapsLogger.debug(LTag.PUMPBTCOMM, "Error confirming command: $sendResult")
return CommandSendErrorConfirming(sendResult.msg)
} }
is MessageSendErrorSending -> is MessageSendErrorSending ->
@ -55,11 +54,8 @@ class Session(
} }
} }
val errMsg = "Maximum number of tries reached. Could not send command\"" val errMsg = "Maximum number of tries reached. Could not send command"
return if (possiblyUnconfirmedCommand) return CommandSendErrorSending(errMsg)
CommandSendErrorConfirming(errMsg)
else
CommandSendErrorSending(errMsg)
} }
@Suppress("ReturnCount") @Suppress("ReturnCount")