diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt index 9fb461b02d..5c096d4410 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/command/BleCommandType.kt @@ -7,7 +7,7 @@ enum class BleCommandType(val value: Byte) { @JvmStatic fun byValue(value: Byte): BleCommandType = - BleCommandType.values().firstOrNull { it.value == value } + values().firstOrNull { it.value == value } ?: throw IllegalArgumentException("Unknown BleCommandType: $value") } } \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt index bca46f8342..16b3da0583 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommand.kt @@ -13,8 +13,8 @@ class GetVersionCommand internal constructor(uniqueId: Int, sequenceNumber: Shor // // override val encoded: ByteArray - get() = HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(LENGTH + HeaderEnabledCommand.Companion.HEADER_LENGTH) // - .put(HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // .put(commandType.value) // .put(BODY_LENGTH) // .putInt(uniqueId) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt index 3d05aada1b..bc4f724f69 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommand.kt @@ -47,8 +47,8 @@ class ProgramBasalCommand internal constructor(private val interlockCommand: Pro } val basalCommand = buffer.array() val interlockCommand = interlockCommand.encoded - val header: ByteArray = HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, (basalCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) - return HeaderEnabledCommand.appendCrc(ByteBuffer.allocate(basalCommand.size + interlockCommand.size + header.size) // + val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (basalCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) + return appendCrc(ByteBuffer.allocate(basalCommand.size + interlockCommand.size + header.size) // .put(header) // .put(interlockCommand) // .put(basalCommand) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt index 70f75a4f11..41d1f15df8 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommand.kt @@ -35,8 +35,8 @@ class ProgramBolusCommand internal constructor(private val interlockCommand: Pro .putInt(0) // Delay between tenth extended pulses in usec .array() val interlockCommand = interlockCommand.encoded - val header: ByteArray = HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, (bolusCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) - return HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + bolusCommand.size) // + val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (bolusCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) + return appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + bolusCommand.size) // .put(header) // .put(interlockCommand) // .put(bolusCommand) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt index 601bf8eb2f..2e3b9d6624 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommand.kt @@ -84,8 +84,8 @@ class ProgramTempBasalCommand protected constructor(private val interlockCommand } val tempBasalCommand = buffer.array() val interlockCommand = interlockCommand.encoded - val header: ByteArray = HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, (tempBasalCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) - return HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + tempBasalCommand.size) // + val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (tempBasalCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag) + return appendCrc(ByteBuffer.allocate(header.size + interlockCommand.size + tempBasalCommand.size) // .put(header) // .put(interlockCommand) // .put(tempBasalCommand) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt index 7772ecec53..f475558220 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommand.kt @@ -19,8 +19,8 @@ class SetUniqueIdCommand internal constructor(uniqueId: Int, sequenceNumber: Sho // // override val encoded: ByteArray - get() = HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(LENGTH + HeaderEnabledCommand.Companion.HEADER_LENGTH) // - .put(HeaderEnabledCommand.Companion.encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) // + get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) // .put(commandType.value) // .put(BODY_LENGTH) // .putInt(uniqueId) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt index 78149ba1c4..ff7072fca6 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommand.kt @@ -12,8 +12,8 @@ class SilenceAlertsCommand internal constructor(uniqueId: Int, sequenceNumber: S override val encoded: ByteArray get() = - HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(LENGTH + HeaderEnabledCommand.Companion.HEADER_LENGTH) // - .put(HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // .put(commandType.value) // .put(BODY_LENGTH) // .putInt(nonce) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt index 95828da199..368a630cb5 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommand.kt @@ -13,8 +13,8 @@ class StopDeliveryCommand internal constructor(uniqueId: Int, sequenceNumber: Sh override val encoded: ByteArray get() { - return HeaderEnabledCommand.Companion.appendCrc(ByteBuffer.allocate(LENGTH + HeaderEnabledCommand.Companion.HEADER_LENGTH) // - .put(HeaderEnabledCommand.Companion.encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + return appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // .put(commandType.value) // .put(BODY_LENGTH) // .putInt(nonce) // diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt index b761611cf9..cfec51058f 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponse.kt @@ -204,11 +204,11 @@ class AlarmStatusResponse(encoded: ByteArray) : AdditionalStatusResponseBase(Add messageLength = (encoded[1].toInt() and 0xff).toShort() additionalStatusResponseType = encoded[2] podStatus = PodStatus.byValue((encoded[3] and 0x0f)) - deliveryStatus = DeliveryStatus.Companion.byValue((encoded[4] and 0x0f)) + deliveryStatus = DeliveryStatus.byValue((encoded[4] and 0x0f)) bolusPulsesRemaining = (ByteBuffer.wrap(byteArrayOf(encoded[5], encoded[6])).short and 2047) sequenceNumberOfLastProgrammingCommand = (encoded[7] and 0x0f).toShort() totalPulsesDelivered = ByteBuffer.wrap(byteArrayOf(encoded[8], encoded[9])).short - alarmType = AlarmType.Companion.byValue(encoded[10]) + alarmType = AlarmType.byValue(encoded[10]) alarmTime = ByteBuffer.wrap(byteArrayOf(encoded[11], encoded[12])).short reservoirPulsesRemaining = ByteBuffer.wrap(byteArrayOf(encoded[13], encoded[14])).short minutesSinceActivation = ByteBuffer.wrap(byteArrayOf(encoded[15], encoded[16])).short diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt index 33aa3b90e3..03dd1b7549 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt @@ -9,7 +9,7 @@ class DefaultStatusResponse(encoded: ByteArray) : ResponseBase(ResponseType.DEFA // TODO: Here is a lot of bitshifting that had to be changed. we should go over it. private val messageType: Byte = encoded[0] private val deliveryStatus: DeliveryStatus = DeliveryStatus.byValue((encoded[1].toInt() shr 4 and 0x0f).toByte()) - private val podStatus: PodStatus = PodStatus.Companion.byValue((encoded[1] and 0x0f) as Byte) + private val podStatus: PodStatus = PodStatus.byValue((encoded[1] and 0x0f) as Byte) private val totalPulsesDelivered: Short = ((encoded[2] and 0x0f shl 12 or (encoded[3].toInt() and 0xff shl 1) or (encoded[4].toInt() and 0xff ushr 7)).toShort()) private val sequenceNumberOfLastProgrammingCommand: Short = (encoded[4] ushr 3 and 0x0f).toShort() private val bolusPulsesRemaining: Short = ((encoded[4] and 0x07 shl 10 or (encoded[5].toInt() and 0xff) and 2047).toShort()) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt index 0c2f8940fc..8b304dec61 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponse.kt @@ -53,7 +53,7 @@ class NakResponse(encoded: ByteArray) : ResponseBase(ResponseType.NAK_RESPONSE, init { messageType = encoded[0] messageLength = encoded[1].toShort() - nakErrorType = NakErrorType.Companion.byValue(encoded[2]) + nakErrorType = NakErrorType.byValue(encoded[2]) val byte3 = encoded[3] val byte4 = encoded[4] if (nakErrorType == NakErrorType.ILLEGAL_SECURITY_CODE) {