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 -> {
if (index != packets.size)
MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
else
if (index == packets.size-1)
MessageSendSuccess
else
MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
}
else ->

View file

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