From 6c9aa9067935ca9251d0886236751b87e48fbdf9 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sun, 28 Mar 2021 23:17:15 +0200 Subject: [PATCH] ktLintFormat --- .../driver/comm/OmnipodDashBleManagerImpl.kt | 12 ++++++++---- .../driver/comm/callbacks/BleCommCallbacks.kt | 3 ++- .../driver/comm/exceptions/BusyException.kt | 2 +- .../exceptions/CouldNotSendCommandException.kt | 2 +- .../exceptions/FailedToConnectException.kt | 1 - .../comm/exceptions/NotConnectedException.kt | 2 +- .../driver/comm/exceptions/PairingException.kt | 2 +- .../pump/omnipod/dash/driver/comm/io/BleIO.kt | 13 +++++++------ .../omnipod/dash/driver/comm/io/CmdBleIO.kt | 1 - .../dash/driver/comm/io/IncomingPackets.kt | 2 +- .../dash/driver/comm/message/MessageIO.kt | 2 +- .../dash/driver/comm/packet/BlePacket.kt | 3 +-- .../dash/driver/comm/pair/LTKExchanger.kt | 2 +- .../dash/driver/comm/session/Connection.kt | 18 +++++++++++++----- .../driver/comm/session/SessionEstablisher.kt | 2 +- 15 files changed, 39 insertions(+), 28 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt index 2408287dea..64b062b699 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt @@ -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)) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt index df01e76e79..e447481a98 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/callbacks/BleCommCallbacks.kt @@ -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( diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BusyException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BusyException.kt index 63e9cd261f..d96b371a9b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BusyException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/BusyException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class BusyException : Exception("Bluetooth busy") \ No newline at end of file +class BusyException : Exception("Bluetooth busy") diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendCommandException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendCommandException.kt index ff7337417b..2299843aa4 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendCommandException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/CouldNotSendCommandException.kt @@ -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) \ No newline at end of file +class CouldNotSendCommandException(val msg: String = "Could not send command") : Exception(msg) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt index c54cb4032f..48cc7470bf 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/FailedToConnectException.kt @@ -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 ?: ""}") } - diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/NotConnectedException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/NotConnectedException.kt index c3675f4167..067091ed78 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/NotConnectedException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/NotConnectedException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class NotConnectedException(val msg: String) : Exception(msg) \ No newline at end of file +class NotConnectedException(val msg: String) : Exception(msg) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/PairingException.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/PairingException.kt index da65b08fec..624f1bb121 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/PairingException.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/exceptions/PairingException.kt @@ -1,3 +1,3 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions -class PairingException(val msg: String) : Exception(msg) \ No newline at end of file +class PairingException(val msg: String) : Exception(msg) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt index 08e9294434..4e45b496d1 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/BleIO.kt @@ -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() } } - - diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt index a5146b9a34..b8fd0e7b65 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/CmdBleIO.kt @@ -51,4 +51,3 @@ class CmdBleIO( } } } - diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/IncomingPackets.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/IncomingPackets.kt index 6ff1b8762a..c18c68cc42 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/IncomingPackets.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/io/IncomingPackets.kt @@ -14,4 +14,4 @@ class IncomingPackets { CharacteristicType.CMD -> dataQueue } } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt index b997c3c92d..06a2c79807 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/message/MessageIO.kt @@ -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()) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt index 38890c484b..7b2b3aa87b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/packet/BlePacket.kt @@ -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 diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt index e5e04608d4..8b954fb39d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/pair/LTKExchanger.kt @@ -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() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt index 9ad5eb4eab..d3d8d1a27b 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/Connection.kt @@ -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 } -} \ No newline at end of file +} diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt index 26c8209c6b..e73796d9b5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/session/SessionEstablisher.kt @@ -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() }" ) }