More formatting

This commit is contained in:
Bart Sopers 2021-02-26 10:41:13 +01:00
parent 29617b5d8c
commit 85140dfb01
32 changed files with 192 additions and 112 deletions

View file

@ -5,13 +5,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.NonceEnabledCommandBuilder
import java.nio.ByteBuffer
class DeactivateCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, nonce: Int) : NonceEnabledCommand(CommandType.DEACTIVATE, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
class DeactivateCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
nonce: Int
) : NonceEnabledCommand(CommandType.DEACTIVATE, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
//
//
//
//
//
override val encoded: ByteArray
get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //

View file

@ -5,13 +5,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.HeaderEnabledCommandBuilder
import java.nio.ByteBuffer
class GetVersionCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean) : HeaderEnabledCommand(CommandType.GET_VERSION, uniqueId, sequenceNumber, multiCommandFlag) {
class GetVersionCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean
) : HeaderEnabledCommand(CommandType.GET_VERSION, uniqueId, sequenceNumber, multiCommandFlag) {
//
//
//
//
//
override val encoded: ByteArray
get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
.put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) //

View file

@ -7,7 +7,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import java.nio.ByteBuffer
import java.util.*
class ProgramAlertsCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, alertConfigurations: List<AlertConfiguration>?, nonce: Int) : NonceEnabledCommand(CommandType.PROGRAM_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
class ProgramAlertsCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
alertConfigurations: List<AlertConfiguration>?,
nonce: Int
) : NonceEnabledCommand(CommandType.PROGRAM_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
private val alertConfigurations: List<AlertConfiguration>

View file

@ -12,7 +12,17 @@ import java.nio.ByteBuffer
import java.util.*
// Always preceded by 0x1a ProgramInsulinCommand
class ProgramBasalCommand internal constructor(private val interlockCommand: ProgramInsulinCommand, uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, insulinProgramElements: List<BasalInsulinProgramElement>?, programReminder: ProgramReminder, currentInsulinProgramElementIndex: Byte, remainingTenthPulsesInCurrentInsulinProgramElement: Short, delayUntilNextTenthPulseInUsec: Int) : HeaderEnabledCommand(CommandType.PROGRAM_BASAL, uniqueId, sequenceNumber, multiCommandFlag) {
class ProgramBasalCommand internal constructor(
private val interlockCommand: ProgramInsulinCommand,
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
insulinProgramElements: List<BasalInsulinProgramElement>,
programReminder: ProgramReminder,
currentInsulinProgramElementIndex: Byte,
remainingTenthPulsesInCurrentInsulinProgramElement: Short,
delayUntilNextTenthPulseInUsec: Int
) : HeaderEnabledCommand(CommandType.PROGRAM_BASAL, uniqueId, sequenceNumber, multiCommandFlag) {
private val insulinProgramElements: List<BasalInsulinProgramElement>
private val programReminder: ProgramReminder
@ -22,17 +32,8 @@ class ProgramBasalCommand internal constructor(private val interlockCommand: Pro
val length: Short
get() = (insulinProgramElements.size * 6 + 10).toShort()
val bodyLength: Byte
get() = (insulinProgramElements.size * 6 + 8).toByte()//
get() = (insulinProgramElements.size * 6 + 8).toByte()
//
//
//
//
//
//
//
//
//
override val encoded: ByteArray
get() {
val buffer = ByteBuffer.allocate(length.toInt()) //
@ -47,7 +48,7 @@ class ProgramBasalCommand internal constructor(private val interlockCommand: Pro
}
val basalCommand = buffer.array()
val interlockCommand = interlockCommand.encoded
val header: ByteArray = encodeHeader(uniqueId, sequenceNumber, (basalCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag)
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) //

View file

@ -9,20 +9,16 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.Mess
import java.nio.ByteBuffer
// NOT SUPPORTED: extended bolus
class ProgramBolusCommand internal constructor(private val interlockCommand: ProgramInsulinCommand, uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, private val programReminder: ProgramReminder, private val numberOfTenthPulses: Short, //
private val delayUntilFirstTenthPulseInUsec: Int) : HeaderEnabledCommand(CommandType.PROGRAM_BOLUS, uniqueId, sequenceNumber, multiCommandFlag) {
class ProgramBolusCommand internal constructor(
private val interlockCommand: ProgramInsulinCommand,
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
private val programReminder: ProgramReminder,
private val numberOfTenthPulses: Short,
private val delayUntilFirstTenthPulseInUsec: Int
) : HeaderEnabledCommand(CommandType.PROGRAM_BOLUS, uniqueId, sequenceNumber, multiCommandFlag) {
//
//
//
//
//
//
//
//
//
// Extended bolus pulses
// Delay between tenth extended pulses in usec
override val encoded: ByteArray
get() {
val bolusCommand = ByteBuffer.allocate(LENGTH.toInt()) //
@ -35,7 +31,7 @@ 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 = encodeHeader(uniqueId, sequenceNumber, (bolusCommand.size + interlockCommand!!.size).toShort(), multiCommandFlag)
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) //

View file

@ -7,7 +7,18 @@ import java.nio.ByteBuffer
import java.util.*
// Always followed by one of: 0x13, 0x16, 0x17
class ProgramInsulinCommand(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, nonce: Int, insulinProgramElements: List<ShortInsulinProgramElement>, private val checksum: Short, private val byte9: Byte, private val byte10And11: Short, private val byte12And13: Short, private val deliveryType: DeliveryType) : NonceEnabledCommand(CommandType.PROGRAM_INSULIN, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
class ProgramInsulinCommand(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
nonce: Int, insulinProgramElements:
List<ShortInsulinProgramElement>,
private val checksum: Short,
private val byte9: Byte,
private val byte10And11: Short,
private val byte12And13: Short,
private val deliveryType: DeliveryType
) : NonceEnabledCommand(CommandType.PROGRAM_INSULIN, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
private val insulinProgramElements: List<ShortInsulinProgramElement> = ArrayList(insulinProgramElements)

View file

@ -11,8 +11,14 @@ import java.nio.ByteBuffer
import java.util.*
// NOT SUPPORTED: percentage temp basal
class ProgramTempBasalCommand protected constructor(private val interlockCommand: ProgramInsulinCommand, uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean,
private val programReminder: ProgramReminder, insulinProgramElements: List<BasalInsulinProgramElement>) : HeaderEnabledCommand(CommandType.PROGRAM_TEMP_BASAL, uniqueId, sequenceNumber, multiCommandFlag) {
class ProgramTempBasalCommand protected constructor(
private val interlockCommand: ProgramInsulinCommand,
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
private val programReminder: ProgramReminder,
insulinProgramElements: List<BasalInsulinProgramElement>
) : HeaderEnabledCommand(CommandType.PROGRAM_TEMP_BASAL, uniqueId, sequenceNumber, multiCommandFlag) {
private val insulinProgramElements: List<BasalInsulinProgramElement>
fun getBodyLength(): Byte = (insulinProgramElements.size * 6 + 8).toByte()

View file

@ -6,18 +6,15 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.b
import java.nio.ByteBuffer
import java.util.*
class SetUniqueIdCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, private val lotNumber: Int, private val podSequenceNumber: Int, private val initializationTime: Date) : HeaderEnabledCommand(CommandType.SET_UNIQUE_ID, uniqueId, sequenceNumber, multiCommandFlag) {
class SetUniqueIdCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
private val lotNumber: Int,
private val podSequenceNumber: Int,
private val initializationTime: Date
) : HeaderEnabledCommand(CommandType.SET_UNIQUE_ID, uniqueId, sequenceNumber, multiCommandFlag) {
//
//
//
//
//
// FIXME ??
// FIXME ??
//
//
//
override val encoded: ByteArray
get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) //
.put(encodeHeader(DEFAULT_UNIQUE_ID, sequenceNumber, LENGTH, multiCommandFlag)) //

View file

@ -1,14 +1,19 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.CommandType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.HeaderEnabledCommand
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.NonceEnabledCommand
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.NonceEnabledCommandBuilder
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.Encodable
import java.nio.ByteBuffer
import java.util.*
class SilenceAlertsCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, private val parameters: SilenceAlertCommandParameters, nonce: Int) : NonceEnabledCommand(CommandType.SILENCE_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
class SilenceAlertsCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
private val parameters: SilenceAlertCommandParameters,
nonce: Int
) : NonceEnabledCommand(CommandType.SILENCE_ALERTS, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
override val encoded: ByteArray
get() =

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.CommandType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.HeaderEnabledCommand
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.NonceEnabledCommand
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.builder.NonceEnabledCommandBuilder
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType
@ -9,7 +8,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import java.nio.ByteBuffer
import java.util.*
class StopDeliveryCommand internal constructor(uniqueId: Int, sequenceNumber: Short, multiCommandFlag: Boolean, private val deliveryType: DeliveryType, private val beepType: BeepType, nonce: Int) : NonceEnabledCommand(CommandType.STOP_DELIVERY, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
class StopDeliveryCommand internal constructor(
uniqueId: Int,
sequenceNumber: Short,
multiCommandFlag: Boolean,
private val deliveryType: DeliveryType,
private val beepType: BeepType,
nonce: Int
) : NonceEnabledCommand(CommandType.STOP_DELIVERY, uniqueId, sequenceNumber, multiCommandFlag, nonce) {
override val encoded: ByteArray
get() {

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base
enum class CommandType(var value: Byte) {
enum class CommandType(
val value: Byte
) {
SET_UNIQUE_ID(0x03.toByte()),
GET_VERSION(0x07.toByte()),
GET_STATUS(0x0e.toByte()),

View file

@ -2,13 +2,15 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.insulin.program.util.ProgramBasalUtil
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.Encodable
import java.io.Serializable
import java.nio.ByteBuffer
open class BasalInsulinProgramElement(val startSlotIndex: Byte, val numberOfSlots: Byte, val totalTenthPulses: Short) : Encodable {
open class BasalInsulinProgramElement(
val startSlotIndex: Byte,
val numberOfSlots: Byte,
val totalTenthPulses: Short
) : Encodable, Serializable {
//
//
//
override val encoded: ByteArray
get() = ByteBuffer.allocate(6) //
.putShort(totalTenthPulses) //

View file

@ -3,15 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
import java.nio.ByteBuffer
import kotlin.experimental.and
class BasalShortInsulinProgramElement(// 4 bits
private val numberOfSlots: Byte, // 10 bits
private val pulsesPerSlot: Short, //
private val extraAlternatePulse: Boolean) : ShortInsulinProgramElement {
class BasalShortInsulinProgramElement(
private val numberOfSlots: Byte, // 4 bits
private val pulsesPerSlot: Short, //10 bits
private val extraAlternatePulse: Boolean
) : ShortInsulinProgramElement {
//
//
//
//
override val encoded: ByteArray
get() {
val firstByte = (numberOfSlots - 1 and 0x0f shl 4 //

View file

@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
import java.nio.ByteBuffer
class BolusShortInsulinProgramElement(private val numberOfPulses: Short) : ShortInsulinProgramElement {
class BolusShortInsulinProgramElement(
private val numberOfPulses: Short
) : ShortInsulinProgramElement {
override val encoded: ByteArray
get() = ByteBuffer.allocate(2).putShort(numberOfPulses).array()

View file

@ -1,6 +1,12 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.insulin.program
class CurrentBasalInsulinProgramElement(val index: Byte, val delayUntilNextTenthPulseInUsec: Int, val remainingTenthPulses: Short) {
import java.io.Serializable
class CurrentBasalInsulinProgramElement(
val index: Byte,
val delayUntilNextTenthPulseInUsec: Int,
val remainingTenthPulses: Short
) : Serializable {
override fun toString(): String = "CurrentLongInsulinProgramElement{" +
"index=" + index +

View file

@ -1,6 +1,12 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.insulin.program
class CurrentSlot(val index: Byte, val eighthSecondsRemaining: Short, val pulsesRemaining: Short) {
import java.io.Serializable
class CurrentSlot(
val index: Byte,
val eighthSecondsRemaining: Short,
val pulsesRemaining: Short
) : Serializable {
override fun toString(): String = "CurrentSlot{" +
"index=" + index +

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.insulin.program
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.Encodable
import java.io.Serializable
interface ShortInsulinProgramElement : Encodable
interface ShortInsulinProgramElement : Encodable, Serializable

View file

@ -2,10 +2,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.
import java.nio.ByteBuffer
class TempBasalInsulinProgramElement(startSlotIndex: Byte, numberOfSlots: Byte, totalTenthPulses: Short) : BasalInsulinProgramElement(startSlotIndex, numberOfSlots, totalTenthPulses) {
class TempBasalInsulinProgramElement(
startSlotIndex: Byte,
numberOfSlots: Byte,
totalTenthPulses: Short
) : BasalInsulinProgramElement(startSlotIndex, numberOfSlots, totalTenthPulses) {
//
//
override val encoded: ByteArray
get() {
val buffer = ByteBuffer.allocate(6)

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class AlarmType(private val value: Byte) {
enum class AlarmType(
private val value: Byte
) {
NONE(0x00.toByte()),
ALARM_PW_FLASH_ERASE(0x01.toByte()),
ALARM_PW_FLASH_WRITE(0x02.toByte()),

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class AlertSlot(val value: Byte) {
enum class AlertSlot(
val value: Byte
) {
AUTO_OFF(0x00.toByte()),
MULTI_COMMAND(0x01.toByte()),
EXPIRATION_IMMINENT(0x02.toByte()),

View file

@ -2,7 +2,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti
import java.util.*
class BasalProgram(segments: List<Segment>) {
class BasalProgram(
segments: List<Segment>
) {
val segments: MutableList<Segment> = segments.toMutableList()
get() = Collections.unmodifiableList(field) // TODO Adrian: moved method here

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
// FIXME names
enum class BeepRepetitionType( // Used in lump of coal alert
enum class BeepRepetitionType(
val value: Byte
) {
XXX(0x01.toByte()), // Used in low reservoir alert
XXX2(0x03.toByte()), // Used in user pod expiration alert
XXX3(0x05.toByte()), // Used in pod expiration alert
XXX4(0x06.toByte()), // Used in imminent pod expiration alert
XXX5(0x08.toByte());
XXX(0x01.toByte()), // Used in lump of coal alert
XXX2(0x03.toByte()), // Used in low reservoir alert
XXX3(0x05.toByte()), // Used in user pod expiration alert
XXX4(0x06.toByte()), // Used in pod expiration alert
XXX5(0x08.toByte()); // Used in imminent pod expiration alert
}

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class DeliveryStatus(private val value: Byte) {
enum class DeliveryStatus(
private val value: Byte
) {
SUSPENDED(0x00.toByte()),
BASAL_ACTIVE(0x01.toByte()),
TEMP_BASAL_ACTIVE(0x02.toByte()),

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class NakErrorType(private val value: Byte) {
enum class NakErrorType(
private val value: Byte
) {
FLASH_WRITE(0x01.toByte()),
FLASH_ERASE(0x02.toByte()),
FLASH_OPERATION(0x03.toByte()),

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class PodStatus(private val value: Byte) {
enum class PodStatus(
private val value: Byte
) {
UNINITIALIZED(0x00.toByte()),
MFG_TEST(0x01.toByte()),
FILLED(0x02.toByte()),

View file

@ -1,8 +1,13 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
import java.io.Serializable
import kotlin.experimental.and
class ProgramReminder(private val atStart: Boolean, private val atEnd: Boolean, private val atInterval: Byte) : Encodable {
class ProgramReminder(
private val atStart: Boolean,
private val atEnd: Boolean,
private val atInterval: Byte
) : Encodable, Serializable {
override val encoded: ByteArray
get() = byteArrayOf(((if (atStart) 1 else 0) shl 7

View file

@ -2,7 +2,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti
import java.io.Serializable
data class SoftwareVersion(private val major: Short, private val minor: Short, private val interim: Short) : Serializable {
data class SoftwareVersion(
private val major: Short,
private val minor: Short,
private val interim: Short
) : Serializable {
override fun toString(): String {
return "$major.$minor.$interim"

View file

@ -2,4 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.AdditionalStatusResponseType
open class AdditionalStatusResponseBase internal constructor(val statusResponseType: AdditionalStatusResponseType, encoded: ByteArray) : ResponseBase(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded)
open class AdditionalStatusResponseBase internal constructor(
val statusResponseType: AdditionalStatusResponseType,
encoded: ByteArray
) : ResponseBase(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded)

View file

@ -8,7 +8,9 @@ import java.nio.ByteBuffer
import java.util.*
import kotlin.experimental.and
class AlarmStatusResponse(encoded: ByteArray) : AdditionalStatusResponseBase(AdditionalStatusResponseType.ALARM_STATUS, encoded) {
class AlarmStatusResponse(
encoded: ByteArray
) : AdditionalStatusResponseBase(AdditionalStatusResponseType.ALARM_STATUS, encoded) {
private val messageType: Byte
private val messageLength: Short

View file

@ -4,7 +4,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definitio
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import kotlin.experimental.and
class DefaultStatusResponse(encoded: ByteArray) : ResponseBase(ResponseType.DEFAULT_STATUS_RESPONSE, encoded) {
class DefaultStatusResponse(
encoded: ByteArray
) : ResponseBase(ResponseType.DEFAULT_STATUS_RESPONSE, encoded) {
// TODO: Here is a lot of bitshifting that had to be changed. we should go over it.
private val messageType: Byte = encoded[0]

View file

@ -3,9 +3,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.NakErrorType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import java.util.*
class NakResponse(encoded: ByteArray) : ResponseBase(ResponseType.NAK_RESPONSE, encoded) {
class NakResponse(
encoded: ByteArray
) : ResponseBase(ResponseType.NAK_RESPONSE, encoded) {
private val messageType: Byte // TODO directly assign here
private val messageLength: Short

View file

@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.ActivationResponseType
import java.nio.ByteBuffer
import java.util.*
import kotlin.experimental.and
class SetUniqueIdResponse(encoded: ByteArray) : ActivationResponseBase(ActivationResponseType.SET_UNIQUE_ID_RESPONSE, encoded) {
class SetUniqueIdResponse(
encoded: ByteArray
) : ActivationResponseBase(ActivationResponseType.SET_UNIQUE_ID_RESPONSE, encoded) {
private val messageType: Byte // TODO directly assign here
private val messageLength: Short
@ -133,20 +133,20 @@ class SetUniqueIdResponse(encoded: ByteArray) : ActivationResponseBase(Activatio
init {
messageType = encoded[0]
messageLength = (encoded[1].toInt() and 0xff) .toShort()
messageLength = (encoded[1].toInt() and 0xff).toShort()
pulseVolumeInTenThousandthMicroLiter = ByteBuffer.wrap(byteArrayOf(encoded[2], encoded[3])).short
pumpRate = (encoded[4].toInt() and 0xff) .toShort()
primePumpRate = (encoded[5].toInt() and 0xff) .toShort()
numberOfEngagingClutchDrivePulses = (encoded[6].toInt() and 0xff) .toShort()
numberOfPrimePulses = (encoded[7].toInt() and 0xff) .toShort()
podExpirationTimeInHours = (encoded[8].toInt() and 0xff) .toShort()
firmwareVersionMajor = (encoded[9].toInt() and 0xff) .toShort()
firmwareVersionMinor = (encoded[10].toInt() and 0xff) .toShort()
firmwareVersionInterim = (encoded[11].toInt() and 0xff) .toShort()
bleVersionMajor = (encoded[12].toInt() and 0xff) .toShort()
bleVersionMinor = (encoded[13].toInt() and 0xff) .toShort()
bleVersionInterim = (encoded[14].toInt() and 0xff) .toShort()
productId = (encoded[15].toInt() and 0xff) .toShort()
pumpRate = (encoded[4].toInt() and 0xff).toShort()
primePumpRate = (encoded[5].toInt() and 0xff).toShort()
numberOfEngagingClutchDrivePulses = (encoded[6].toInt() and 0xff).toShort()
numberOfPrimePulses = (encoded[7].toInt() and 0xff).toShort()
podExpirationTimeInHours = (encoded[8].toInt() and 0xff).toShort()
firmwareVersionMajor = (encoded[9].toInt() and 0xff).toShort()
firmwareVersionMinor = (encoded[10].toInt() and 0xff).toShort()
firmwareVersionInterim = (encoded[11].toInt() and 0xff).toShort()
bleVersionMajor = (encoded[12].toInt() and 0xff).toShort()
bleVersionMinor = (encoded[13].toInt() and 0xff).toShort()
bleVersionInterim = (encoded[14].toInt() and 0xff).toShort()
productId = (encoded[15].toInt() and 0xff).toShort()
podStatus = PodStatus.byValue(encoded[16])
lotNumber = ByteBuffer.wrap(byteArrayOf(0, 0, 0, 0, encoded[17], encoded[18], encoded[19], encoded[20])).long
podSequenceNumber = ByteBuffer.wrap(byteArrayOf(0, 0, 0, 0, encoded[21], encoded[22], encoded[23], encoded[24])).long