detekt
This commit is contained in:
parent
89bcd52994
commit
470b21aad4
|
@ -61,7 +61,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(
|
|||
emitter.onNext(PodEvent.CommandSendNotConfirmed(cmd))
|
||||
}
|
||||
|
||||
when (val readResult = session.readAndAckCommandResponse()) {
|
||||
when (val readResult = session.readAndAckResponse()) {
|
||||
is CommandReceiveSuccess ->
|
||||
emitter.onNext(PodEvent.ResponseReceived(readResult.result))
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ class BleCommCallbacks(
|
|||
} else {
|
||||
aapsLogger.warn(
|
||||
LTag.PUMPBTCOMM,
|
||||
"Could not confirm write. Got " + received.payload.toHex() + ".Excepted: " + expectedPayload.toHex()
|
||||
"Could not confirm write. Got " + received.payload.toHex() +
|
||||
".Excepted: " + expectedPayload.toHex()
|
||||
)
|
||||
WriteConfirmationError("Received incorrect writeConfirmation")
|
||||
}
|
||||
|
|
|
@ -153,27 +153,27 @@ class MessageIO(
|
|||
val peekCmd = cmdBleIO.peekCommand()
|
||||
?: return MessageSendSuccess
|
||||
|
||||
when (val receivedCmd = BleCommand.parse(peekCmd)) {
|
||||
return when (val receivedCmd = BleCommand.parse(peekCmd)) {
|
||||
is BleCommandNack -> {
|
||||
// // Consume NACK
|
||||
val received = cmdBleIO.receivePacket()
|
||||
if (received !is BleReceivePayload) {
|
||||
return MessageSendErrorSending(received.toString())
|
||||
MessageSendErrorSending(received.toString())
|
||||
} else {
|
||||
val sendResult = dataBleIO.sendAndConfirmPacket(packets[receivedCmd.idx.toInt()].toByteArray())
|
||||
handleSendResult(sendResult, index, packets)
|
||||
}
|
||||
|
||||
val sendResult = dataBleIO.sendAndConfirmPacket(packets[receivedCmd.idx.toInt()].toByteArray())
|
||||
return handleSendResult(sendResult, index, packets)
|
||||
}
|
||||
|
||||
BleCommandSuccess -> {
|
||||
if (index != packets.size) {
|
||||
return MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
|
||||
}
|
||||
return MessageSendSuccess
|
||||
if (index != packets.size)
|
||||
MessageSendErrorSending("Received SUCCESS before sending all the data. $index")
|
||||
else
|
||||
MessageSendSuccess
|
||||
}
|
||||
|
||||
else ->
|
||||
return MessageSendErrorSending("Received unexpected command: ${peekCmd.toHex()}")
|
||||
MessageSendErrorSending("Received unexpected command: ${peekCmd.toHex()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ data class FirstBlePacket(
|
|||
}
|
||||
if (payload[0].toInt() != 0) {
|
||||
// most likely we lost the first packet.
|
||||
// TODO: try to recover with NACKs?
|
||||
throw IncorrectPacketException(payload, 0)
|
||||
}
|
||||
val fullFragments = payload[1].toInt()
|
||||
|
|
|
@ -62,7 +62,7 @@ class Session(
|
|||
CommandSendErrorSending(errMsg)
|
||||
}
|
||||
|
||||
fun readAndAckCommandResponse(): CommandReceiveResult {
|
||||
fun readAndAckResponse(): CommandReceiveResult {
|
||||
var responseMsgPacket: MessagePacket? = null
|
||||
for (i in 0..MAX_TRIES) {
|
||||
val responseMsg = msgIO.receiveMessage()
|
||||
|
@ -72,9 +72,9 @@ class Session(
|
|||
}
|
||||
responseMsgPacket = responseMsg.msg
|
||||
}
|
||||
if (responseMsgPacket == null) {
|
||||
return CommandReceiveError("Could not read response")
|
||||
}
|
||||
|
||||
responseMsgPacket
|
||||
?: return CommandReceiveError("Could not read response")
|
||||
|
||||
val decrypted = enDecrypt.decrypt(responseMsgPacket)
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response: $decrypted")
|
||||
|
|
|
@ -75,7 +75,7 @@ class SessionEstablisher(
|
|||
|
||||
val eapMsg = EapMessage(
|
||||
code = EapCode.REQUEST,
|
||||
identifier = identifier, // TODO: find what value we need here, it's probably random
|
||||
identifier = identifier,
|
||||
attributes = attributes
|
||||
)
|
||||
return MessagePacket(
|
||||
|
|
Loading…
Reference in a new issue