Formatting after Kotlin conversion

This commit is contained in:
Bart Sopers 2021-02-26 10:04:33 +01:00
parent cc3b9b7f32
commit 1a12d6cd9d
18 changed files with 259 additions and 35 deletions

View file

@ -28,8 +28,8 @@ class OmnipodDashPumpPlugin @Inject constructor(
injector: HasAndroidInjector,
aapsLogger: AAPSLogger,
resourceHelper: ResourceHelper,
commandQueue: CommandQueueProvider)
: PumpPluginBase(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue), PumpInterface {
commandQueue: CommandQueueProvider
) : PumpPluginBase(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue), PumpInterface {
companion object {

View file

@ -1,8 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.Encodable
import java.io.Serializable
interface Command : Encodable {
interface Command : Encodable, Serializable {
val commandType: CommandType
}

View file

@ -3,8 +3,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti
import java.nio.ByteBuffer
import kotlin.experimental.or
class AlertConfiguration(private val slot: AlertSlot, private val enabled: Boolean, private val durationInMinutes: Short, private val autoOff: Boolean, private val triggerType: AlertTriggerType, private val offsetInMinutesOrThresholdInMicroLiters: Short, private val beepType: BeepType, private val beepRepetition: BeepRepetitionType) : Encodable {
class AlertConfiguration(
private val slot: AlertSlot,
private val enabled: Boolean,
private val durationInMinutes: Short,
private val autoOff: Boolean,
private val triggerType: AlertTriggerType,
private val offsetInMinutesOrThresholdInMicroLiters: Short,
private val beepType: BeepType,
private val beepRepetition: BeepRepetitionType
) : Encodable {
override val encoded: ByteArray
get() {

View file

@ -1,7 +1,15 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class AlertSlot(val value: Byte) {
AUTO_OFF(0x00.toByte()), MULTI_COMMAND(0x01.toByte()), EXPIRATION_IMMINENT(0x02.toByte()), USER_SET_EXPIRATION(0x03.toByte()), LOW_RESERVOIR(0x04.toByte()), SUSPEND_IN_PROGRESS(0x05.toByte()), SUSPEND_ENDED(0x06.toByte()), EXPIRATION(0x07.toByte()), UNKNOWN(0xff.toByte());
AUTO_OFF(0x00.toByte()),
MULTI_COMMAND(0x01.toByte()),
EXPIRATION_IMMINENT(0x02.toByte()),
USER_SET_EXPIRATION(0x03.toByte()),
LOW_RESERVOIR(0x04.toByte()),
SUSPEND_IN_PROGRESS(0x05.toByte()),
SUSPEND_ENDED(0x06.toByte()),
EXPIRATION(0x07.toByte()),
UNKNOWN(0xff.toByte());
companion object {

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class AlertTriggerType {
TIME_TRIGGER, RESERVOIR_VOLUME_TRIGGER
TIME_TRIGGER,
RESERVOIR_VOLUME_TRIGGER
}

View file

@ -2,7 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definiti
// FIXME names
enum class BeepRepetitionType( // Used in lump of coal alert
val value: Byte) {
val value: Byte
) {
XXX(0x01.toByte()), // Used in low reservoir alert
XXX2(0x03.toByte()), // Used in user pod expiration alert

View file

@ -1,8 +1,10 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class BeepType( // Used in stop delivery command
val value: Byte) {
val value: Byte
) {
SILENT(0x00.toByte()), FOUR_TIMES_BIP_BEEP(0x02.toByte()), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert
SILENT(0x00.toByte()),
FOUR_TIMES_BIP_BEEP(0x02.toByte()), // Used in low reservoir alert, user expiration alert, expiration alert, imminent expiration alert, lump of coal alert
LONG_SINGLE_BEEP(0x06.toByte());
}

View file

@ -1,7 +1,13 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class DeliveryStatus(private val value: Byte) {
SUSPENDED(0x00.toByte()), BASAL_ACTIVE(0x01.toByte()), TEMP_BASAL_ACTIVE(0x02.toByte()), PRIMING(0x04.toByte()), BOLUS_AND_BASAL_ACTIVE(0x05.toByte()), BOLUS_AND_TEMP_BASAL_ACTIVE(0x06.toByte()), UNKNOWN(0xff.toByte());
SUSPENDED(0x00.toByte()),
BASAL_ACTIVE(0x01.toByte()),
TEMP_BASAL_ACTIVE(0x02.toByte()),
PRIMING(0x04.toByte()),
BOLUS_AND_BASAL_ACTIVE(0x05.toByte()),
BOLUS_AND_TEMP_BASAL_ACTIVE(0x06.toByte()),
UNKNOWN(0xff.toByte());
companion object {

View file

@ -1,7 +1,36 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
enum class NakErrorType(private val value: Byte) {
FLASH_WRITE(0x01.toByte()), FLASH_ERASE(0x02.toByte()), FLASH_OPERATION(0x03.toByte()), FLASH_ADDR(0x04.toByte()), POD_STATE(0x05.toByte()), CRITICAL_VARIABLE(0x06.toByte()), ILLEGAL_PARAM(0x07.toByte()), BOLUS_CRITICAL_VAR(0x08.toByte()), INT_ILLEGAL_PARAM(0x09.toByte()), ILLEGAL_CHECKSUM(0x0a.toByte()), INVALID_MSG_LEN(0x0b.toByte()), PUMP_STATE(0x0c.toByte()), ILLEGAL_COMMAND(0x0d.toByte()), ILLEGAL_FILL_STATE(0x0e.toByte()), MAX_READWRITE_SIZE(0x0f.toByte()), ILLEGAL_READ_ADDRESS(0x10.toByte()), ILLEGAL_READ_MEM_TYPE(0x11.toByte()), INIT_POD(0x12.toByte()), ILLEGAL_CMD_STATE(0x13.toByte()), ILLEGAL_SECURITY_CODE(0x14.toByte()), POD_IN_ALARM(0x15.toByte()), COMD_NOT_SET(0x16.toByte()), ILLEGAL_RX_SENS_VALUE(0x17.toByte()), ILLEGAL_TX_PKT_SIZE(0x18.toByte()), OCCL_PARAMS_ALREADY_SET(0x19.toByte()), OCCL_PARAM(0x1a.toByte()), ILLEGAL_CDTHR_VALUE(0x1b.toByte()), IGNORE_COMMAND(0x1c.toByte()), INVALID_CRC(0x1d.toByte()), UNKNOWN(0xff.toByte());
FLASH_WRITE(0x01.toByte()),
FLASH_ERASE(0x02.toByte()),
FLASH_OPERATION(0x03.toByte()),
FLASH_ADDR(0x04.toByte()),
POD_STATE(0x05.toByte()),
CRITICAL_VARIABLE(0x06.toByte()),
ILLEGAL_PARAM(0x07.toByte()),
BOLUS_CRITICAL_VAR(0x08.toByte()),
INT_ILLEGAL_PARAM(0x09.toByte()),
ILLEGAL_CHECKSUM(0x0a.toByte()),
INVALID_MSG_LEN(0x0b.toByte()),
PUMP_STATE(0x0c.toByte()),
ILLEGAL_COMMAND(0x0d.toByte()),
ILLEGAL_FILL_STATE(0x0e.toByte()),
MAX_READWRITE_SIZE(0x0f.toByte()),
ILLEGAL_READ_ADDRESS(0x10.toByte()),
ILLEGAL_READ_MEM_TYPE(0x11.toByte()),
INIT_POD(0x12.toByte()),
ILLEGAL_CMD_STATE(0x13.toByte()),
ILLEGAL_SECURITY_CODE(0x14.toByte()),
POD_IN_ALARM(0x15.toByte()),
COMD_NOT_SET(0x16.toByte()),
ILLEGAL_RX_SENS_VALUE(0x17.toByte()),
ILLEGAL_TX_PKT_SIZE(0x18.toByte()),
OCCL_PARAMS_ALREADY_SET(0x19.toByte()),
OCCL_PARAM(0x1a.toByte()),
ILLEGAL_CDTHR_VALUE(0x1b.toByte()),
IGNORE_COMMAND(0x1c.toByte()),
INVALID_CRC(0x1d.toByte()),
UNKNOWN(0xff.toByte());
companion object {

View file

@ -1,7 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition
class OmnipodEvent {
enum class OmnipodEventType {
CONNECTED, ALREADY_CONNECTED, FAILED_TO_CONNECT, DISCONNECTED, COMMAND_SENT, GOT_POD_VERSION, SET_UNIQUE_ID, PRIMED_PUMP, FINISHED_ACTIVATION_1, PROGRAMMED_BASAL, PROGRAMMED_ALERTS, SET_BEEPS, INSERTED_CANNULA, FINISHED_ACTIVATION_2, PROGRAMMED_TEMP_BASAL, STARTED_BOLUS, STOPPED_DELIVERY, SILENCED_ALERTS, DEACTIVATED, COMMAND_SENDING
}
}

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.ActivationResponseType
abstract class ActivationResponseBase(val activationResponseType: ActivationResponseType, encoded: ByteArray) : ResponseBase(ResponseType.ACTIVATION_RESPONSE, encoded)
abstract class ActivationResponseBase(
val activationResponseType: ActivationResponseType,
encoded: ByteArray
) : ResponseBase(ResponseType.ACTIVATION_RESPONSE, encoded)

View file

@ -1,6 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.*
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlarmType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.DeliveryStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.AdditionalStatusResponseType
import java.nio.ByteBuffer
import java.util.*
@ -38,6 +40,7 @@ class AlarmStatusResponse(encoded: ByteArray) : AdditionalStatusResponseBase(Add
private val receiverLowerGain: Short
private val podStatusWhenAlarmOccurred2: PodStatus
private val returnAddressOfPodAlarmHandlerCaller: Short
fun getMessageType(): Byte {
return messageType
}

View file

@ -1,6 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
interface Response {
import java.io.Serializable
interface Response : Serializable {
val responseType: ResponseType
val encoded: ByteArray

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
abstract class ResponseBase(override val responseType: ResponseType, encoded: ByteArray) : Response {
abstract class ResponseBase(
override val responseType: ResponseType,
encoded: ByteArray
) : Response {
override val encoded: ByteArray = encoded.copyOf(encoded.size)

View file

@ -1,7 +1,14 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response
enum class ResponseType(private val value: Byte) {
ACTIVATION_RESPONSE(0x01.toByte()), DEFAULT_STATUS_RESPONSE(0x1d.toByte()), ADDITIONAL_STATUS_RESPONSE(0x02.toByte()), NAK_RESPONSE(0x06.toByte()), UNKNOWN(0xff.toByte());
enum class ResponseType(
private val value: Byte
) {
ACTIVATION_RESPONSE(0x01.toByte()),
DEFAULT_STATUS_RESPONSE(0x1d.toByte()),
ADDITIONAL_STATUS_RESPONSE(0x02.toByte()),
NAK_RESPONSE(0x06.toByte()),
UNKNOWN(0xff.toByte());
fun getValue(): Byte {
return value

View file

@ -27,6 +27,7 @@ class SetUniqueIdResponse(encoded: ByteArray) : ActivationResponseBase(Activatio
private val lotNumber: Long
private val podSequenceNumber: Long
private val uniqueIdReceivedInCommand: Long
fun getMessageType(): Byte {
return messageType
}

View file

@ -6,17 +6,19 @@ import java.nio.ByteBuffer
import java.util.*
import kotlin.experimental.and
class VersionResponse(encoded: ByteArray) : ActivationResponseBase(ActivationResponseType.GET_VERSION_RESPONSE, encoded) {
class VersionResponse(
encoded: ByteArray
) : ActivationResponseBase(ActivationResponseType.GET_VERSION_RESPONSE, encoded) {
private val messageType: Byte = encoded[0]
private val messageLength: Short = (encoded[1].toInt() and 0xff) .toShort()
private val firmwareVersionMajor: Short = (encoded[2].toInt() and 0xff) .toShort()
private val firmwareVersionMinor: Short = (encoded[3].toInt() and 0xff) .toShort()
private val firmwareVersionInterim: Short = (encoded[4].toInt() and 0xff) .toShort()
private val bleVersionMajor: Short = (encoded[5].toInt() and 0xff) .toShort()
private val bleVersionMinor: Short = (encoded[6].toInt() and 0xff) .toShort()
private val bleVersionInterim: Short = (encoded[7].toInt() and 0xff) .toShort()
private val productId: Short = (encoded[8].toInt() and 0xff) .toShort()
private val messageLength: Short = (encoded[1].toInt() and 0xff).toShort()
private val firmwareVersionMajor: Short = (encoded[2].toInt() and 0xff).toShort()
private val firmwareVersionMinor: Short = (encoded[3].toInt() and 0xff).toShort()
private val firmwareVersionInterim: Short = (encoded[4].toInt() and 0xff).toShort()
private val bleVersionMajor: Short = (encoded[5].toInt() and 0xff).toShort()
private val bleVersionMinor: Short = (encoded[6].toInt() and 0xff).toShort()
private val bleVersionInterim: Short = (encoded[7].toInt() and 0xff).toShort()
private val productId: Short = (encoded[8].toInt() and 0xff).toShort()
private val podStatus: PodStatus = PodStatus.byValue((encoded[9] and 0xf))
private val lotNumber: Long = ByteBuffer.wrap(byteArrayOf(0, 0, 0, 0, encoded[10], encoded[11], encoded[12], encoded[13])).long
private val podSequenceNumber: Long = ByteBuffer.wrap(byteArrayOf(0, 0, 0, 0, encoded[14], encoded[15], encoded[16], encoded[17])).long