ktLintFormat

This commit is contained in:
Andrei Vereha 2021-03-28 23:17:15 +02:00
parent b630c4d21a
commit 6c9aa90679
15 changed files with 39 additions and 28 deletions

View file

@ -166,10 +166,14 @@ class OmnipodDashBleManagerImpl @Inject constructor(
emitter.onNext(PodEvent.Pairing)
val ltkExchanger = LTKExchanger(
aapsLogger, conn.msgIO, myId, podId, Id.fromLong(
PodScanner
.POD_ID_NOT_ACTIVATED
)
aapsLogger,
conn.msgIO,
myId,
podId,
Id.fromLong(
PodScanner
.POD_ID_NOT_ACTIVATED
)
)
val pairResult = ltkExchanger.negotiateLTK()
emitter.onNext(PodEvent.Paired(podId))

View file

@ -63,7 +63,8 @@ class BleCommCallbacks(
null -> return WriteConfirmationError("Timeout waiting for writeConfirmation")
is WriteConfirmationSuccess ->
if (expectedPayload.contentEquals(received.payload) &&
expectedUUID == received.uuid) {
expectedUUID == received.uuid
) {
received
} else {
aapsLogger.warn(

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
class BusyException : Exception("Bluetooth busy")
class BusyException : Exception("Bluetooth busy")

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
class CouldNotSendCommandException(val msg: String = "Could not send command") : Exception(msg)
class CouldNotSendCommandException(val msg: String = "Could not send command") : Exception(msg)

View file

@ -3,4 +3,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.excepti
open class FailedToConnectException : Exception {
constructor(message: String? = null) : super("Failed to connect: ${message ?: ""}")
}

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
class NotConnectedException(val msg: String) : Exception(msg)
class NotConnectedException(val msg: String) : Exception(msg)

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions
class PairingException(val msg: String) : Exception(msg)
class PairingException(val msg: String) : Exception(msg)

View file

@ -66,10 +66,13 @@ abstract class BleIO(
return BleSendErrorSending("Could not writeCharacteristic on {$type.name}")
}
return when (val confirmation = bleCommCallbacks.confirmWrite(
payload, type.value,
DEFAULT_IO_TIMEOUT_MS
)) {
return when (
val confirmation = bleCommCallbacks.confirmWrite(
payload,
type.value,
DEFAULT_IO_TIMEOUT_MS
)
) {
is WriteConfirmationError ->
BleSendErrorConfirming(confirmation.msg)
is WriteConfirmationSuccess ->
@ -127,5 +130,3 @@ abstract class BleIO(
const val DEFAULT_IO_TIMEOUT_MS = 1000.toLong()
}
}

View file

@ -14,4 +14,4 @@ class IncomingPackets {
CharacteristicType.CMD -> dataQueue
}
}
}
}

View file

@ -155,7 +155,7 @@ class MessageIO(
when (val receivedCmd = BleCommand.parse(peekCmd)) {
is BleCommandNack -> {
//// Consume NACK
// // Consume NACK
val received = cmdBleIO.receivePacket()
if (received !is BleReceivePayload) {
return MessageSendErrorSending(received.toString())

View file

@ -55,7 +55,7 @@ data class FirstBlePacket(
throw IncorrectPacketException(payload, 0)
}
val fullFragments = payload[1].toInt()
require(fullFragments < MAX_FRAGMENTS) { "Received more than ${MAX_FRAGMENTS} fragments" }
require(fullFragments < MAX_FRAGMENTS) { "Received more than $MAX_FRAGMENTS fragments" }
when {
// Without middle packets
payload.size < HEADER_SIZE_WITHOUT_MIDDLE_PACKETS ->
@ -196,7 +196,6 @@ data class LastOptionalPlusOneBlePacket(
),
size = size.toByte(),
)
}
private const val HEADER_SIZE = 2

View file

@ -48,7 +48,7 @@ internal class LTKExchanger(
val sps2 = sps2()
val sp2Result = msgIO.sendMessage(sps2.messagePacket)
if (sp1Result !is MessageSendSuccess) {
throw PairingException("Could not send sps2: ${sp2Result}")
throw PairingException("Could not send sps2: $sp2Result")
}
val podSps2 = msgIO.receiveMessage()

View file

@ -49,12 +49,20 @@ class Connection(val podDevice: BluetoothDevice, private val aapsLogger: AAPSLog
private val discoverer = ServiceDiscoverer(aapsLogger, gattConnection, bleCommCallbacks)
private val discoveredCharacteristics = discoverer.discoverServices()
private val cmdBleIO = CmdBleIO(
aapsLogger, discoveredCharacteristics[CharacteristicType.CMD]!!, incomingPackets
.cmdQueue, gattConnection, bleCommCallbacks
aapsLogger,
discoveredCharacteristics[CharacteristicType.CMD]!!,
incomingPackets
.cmdQueue,
gattConnection,
bleCommCallbacks
)
private val dataBleIO = DataBleIO(
aapsLogger, discoveredCharacteristics[CharacteristicType.DATA]!!, incomingPackets
.dataQueue, gattConnection, bleCommCallbacks
aapsLogger,
discoveredCharacteristics[CharacteristicType.DATA]!!,
incomingPackets
.dataQueue,
gattConnection,
bleCommCallbacks
)
val msgIO = MessageIO(aapsLogger, cmdBleIO, dataBleIO)
var session: Session? = null
@ -123,4 +131,4 @@ class Connection(val podDevice: BluetoothDevice, private val aapsLogger: AAPSLog
private const val CONNECT_TIMEOUT_MS = 7000
}
}
}

View file

@ -101,7 +101,7 @@ class SessionEstablisher(
if (eapMsg.attributes.size == 1 && eapMsg.attributes[0] is EapAkaAttributeClientErrorCode) {
throw SessionEstablishmentException(
"Received CLIENT_ERROR_CODE for EAP-AKA challenge: ${
eapMsg.attributes[0].toByteArray().toHex()
eapMsg.attributes[0].toByteArray().toHex()
}"
)
}