diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt index fdb08804b3..3063c6de12 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManager.kt @@ -1,8 +1,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import io.reactivex.Observable +import java.util.* interface OmnipodDashManager { @@ -26,7 +29,11 @@ interface OmnipodDashManager { fun cancelBolus(): Observable - fun silenceAlerts(): Observable + fun programBeeps(): Observable + + fun programAlerts(alertConfigurations: List): Observable + + fun silenceAlerts(alerts: EnumSet): Observable fun deactivatePod(): Observable } \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt index 2b2e968b55..0385a74619 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/OmnipodDashManagerImpl.kt @@ -2,10 +2,13 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.OmnipodDashBleManager -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.event.PodEvent +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.OmnipodDashPodStateManager import io.reactivex.Observable +import java.util.* import javax.inject.Inject import javax.inject.Singleton @@ -66,7 +69,17 @@ class OmnipodDashManagerImpl @Inject constructor( return Observable.empty() } - override fun silenceAlerts(): Observable { + override fun programBeeps(): Observable { + // TODO + return Observable.empty() + } + + override fun programAlerts(alertConfigurations: List): Observable { + // TODO + return Observable.empty() + } + + override fun silenceAlerts(alerts: EnumSet): Observable { // TODO return Observable.empty() } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt new file mode 100644 index 0000000000..c08b251cb4 --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommand.kt @@ -0,0 +1,46 @@ +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.builder.HeaderEnabledCommandBuilder +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType +import java.nio.ByteBuffer + +class GetStatusCommand( + uniqueId: Int, + sequenceNumber: Short, + multiCommandFlag: Boolean, + private val statusResponseType: ResponseType.StatusResponseType +) : HeaderEnabledCommand(CommandType.GET_STATUS, uniqueId, sequenceNumber, multiCommandFlag) { + + override val encoded: ByteArray + get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .put(statusResponseType.value) // + .array()) + + class Builder : HeaderEnabledCommandBuilder() { + + private var statusResponseType: ResponseType.StatusResponseType? = null + + fun setStatusResponseType(statusResponseType: ResponseType.StatusResponseType): Builder { + this.statusResponseType = statusResponseType + return this + } + + override fun buildCommand(): GetStatusCommand { + requireNotNull(statusResponseType) { "immediateBeepType can not be null" } + + return GetStatusCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, statusResponseType!!) + } + + } + + companion object { + + private const val LENGTH: Short = 3 + private const val BODY_LENGTH: Byte = 1 + } +} \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt new file mode 100644 index 0000000000..f000270bd5 --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommand.kt @@ -0,0 +1,73 @@ +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.builder.HeaderEnabledCommandBuilder +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder +import java.nio.ByteBuffer + +class ProgramBeepsCommand internal constructor( + uniqueId: Int, + sequenceNumber: Short, + multiCommandFlag: Boolean, + private val immediateBeepType: BeepType, + private val basalReminder: ProgramReminder, + private val tempBasalReminder: ProgramReminder, + private val bolusReminder: ProgramReminder +) : HeaderEnabledCommand(CommandType.PROGRAM_BEEPS, uniqueId, sequenceNumber, multiCommandFlag) { + + override val encoded: ByteArray + get() = appendCrc(ByteBuffer.allocate(LENGTH + HEADER_LENGTH) // + .put(encodeHeader(uniqueId, sequenceNumber, LENGTH, multiCommandFlag)) // + .put(commandType.value) // + .put(BODY_LENGTH) // + .put(immediateBeepType.value) // + .put(basalReminder.encoded) // + .put(tempBasalReminder.encoded) // + .put(bolusReminder.encoded) // + .array()) + + class Builder : HeaderEnabledCommandBuilder() { + + private var immediateBeepType: BeepType? = null + private var basalReminder: ProgramReminder? = null + private var tempBasalReminder: ProgramReminder? = null + private var bolusReminder: ProgramReminder? = null + + fun setImmediateBeepType(beepType: BeepType): Builder { + this.immediateBeepType = beepType + return this + } + + fun setBasalReminder(programReminder: ProgramReminder): Builder { + this.basalReminder = programReminder + return this + } + + fun setTempBasalReminder(programReminder: ProgramReminder): Builder { + this.tempBasalReminder = programReminder + return this + } + + fun setBolusReminder(programReminder: ProgramReminder): Builder { + this.bolusReminder = programReminder + return this + } + + override fun buildCommand(): ProgramBeepsCommand { + requireNotNull(immediateBeepType) { "immediateBeepType can not be null" } + requireNotNull(basalReminder) { "basalReminder can not be null" } + requireNotNull(tempBasalReminder) { "tempBasalReminder can not be null" } + requireNotNull(bolusReminder) { "bolusReminder can not be null" } + + return ProgramBeepsCommand(uniqueId!!, sequenceNumber!!, multiCommandFlag, immediateBeepType!!, basalReminder!!, tempBasalReminder!!, bolusReminder!!) + } + } + + companion object { + + private const val LENGTH: Short = 6 + private const val BODY_LENGTH: Byte = 4 + } +} \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt index 414a710723..0ce01d962d 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AdditionalStatusResponseBase.kt @@ -1,8 +1,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.AdditionalStatusResponseType +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.StatusResponseType open class AdditionalStatusResponseBase internal constructor( - val statusResponseType: AdditionalStatusResponseType, + val statusResponseType: StatusResponseType, encoded: ByteArray ) : ResponseBase(ResponseType.ADDITIONAL_STATUS_RESPONSE, encoded) \ No newline at end of file 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 4cce00a1c6..736213161a 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 @@ -3,14 +3,14 @@ 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.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 info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType.StatusResponseType import java.nio.ByteBuffer import java.util.* import kotlin.experimental.and class AlarmStatusResponse( encoded: ByteArray -) : AdditionalStatusResponseBase(AdditionalStatusResponseType.ALARM_STATUS, encoded) { +) : AdditionalStatusResponseBase(StatusResponseType.ALARM_STATUS, encoded) { private val messageType: Byte private val messageLength: Short diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt index 6c6c19ae80..ad08b4b3ec 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/ResponseType.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response enum class ResponseType( - private val value: Byte + val value: Byte ) { ACTIVATION_RESPONSE(0x01.toByte()), @@ -10,20 +10,25 @@ enum class ResponseType( NAK_RESPONSE(0x06.toByte()), UNKNOWN(0xff.toByte()); - fun getValue(): Byte { - return value - } + enum class StatusResponseType( + val value: Byte + ) { - enum class AdditionalStatusResponseType(private val value: Byte) { - STATUS_RESPONSE_PAGE_1(0x01.toByte()), ALARM_STATUS(0x02.toByte()), STATUS_RESPONSE_PAGE_3(0x03.toByte()), STATUS_RESPONSE_PAGE_5(0x05.toByte()), STATUS_RESPONSE_PAGE_6(0x06.toByte()), STATUS_RESPONSE_PAGE_70(0x46.toByte()), STATUS_RESPONSE_PAGE_80(0x50.toByte()), STATUS_RESPONSE_PAGE_81(0x51.toByte()), UNKNOWN(0xff.toByte()); - - fun getValue(): Byte { - return value - } + DEFAULT_STATUS_RESPONSE(0x00.toByte()), + STATUS_RESPONSE_PAGE_1(0x01.toByte()), + ALARM_STATUS(0x02.toByte()), + STATUS_RESPONSE_PAGE_3(0x03.toByte()), + STATUS_RESPONSE_PAGE_5(0x05.toByte()), + STATUS_RESPONSE_PAGE_6(0x06.toByte()), + STATUS_RESPONSE_PAGE_70(0x46.toByte()), + STATUS_RESPONSE_PAGE_80(0x50.toByte()), + STATUS_RESPONSE_PAGE_81(0x51.toByte()), + UNKNOWN(0xff.toByte()); companion object { - fun byValue(value: Byte): AdditionalStatusResponseType { + @JvmStatic + fun byValue(value: Byte): StatusResponseType { for (type in values()) { if (type.value == value) { return type @@ -34,11 +39,17 @@ enum class ResponseType( } } - enum class ActivationResponseType(private val length: Byte) { - GET_VERSION_RESPONSE(0x15.toByte()), SET_UNIQUE_ID_RESPONSE(0x1b.toByte()), UNKNOWN(0xff.toByte()); + enum class ActivationResponseType( + val length: Byte + ) { + + GET_VERSION_RESPONSE(0x15.toByte()), + SET_UNIQUE_ID_RESPONSE(0x1b.toByte()), + UNKNOWN(0xff.toByte()); companion object { + @JvmStatic fun byLength(length: Byte): ActivationResponseType { for (type in values()) { if (type.length == length) { @@ -52,6 +63,7 @@ enum class ResponseType( companion object { + @JvmStatic fun byValue(value: Byte): ResponseType { for (type in values()) { if (type.value == value) { diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.java deleted file mode 100644 index 4ffb19a702..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -public class DeactivateCommandTest { - @Test - public void testEncoding() throws DecoderException { - byte[] encoded = new DeactivateCommand.Builder() // - .setUniqueId(37879809) // - .setSequenceNumber((short) 5) // - .setNonce(1229869870) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt new file mode 100644 index 0000000000..55dc2ff96e --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/DeactivateCommandTest.kt @@ -0,0 +1,20 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class DeactivateCommandTest { + + @Test @Throws(DecoderException::class) fun testEncoding() { + val encoded = DeactivateCommand.Builder() // + .setUniqueId(37879809) // + .setSequenceNumber(5.toShort()) // + .setNonce(1229869870) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("0242000114061C04494E532E001C"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt new file mode 100644 index 0000000000..4a73a9ebb4 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetStatusCommandTest.kt @@ -0,0 +1,21 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class GetStatusCommandTest { + + @Test @Throws(DecoderException::class) fun testGetDefaultStatusResponse() { + val encoded = GetStatusCommand.Builder() // + .setUniqueId(37879810) // + .setSequenceNumber(15.toShort()) // + .setStatusResponseType(ResponseType.StatusResponseType.DEFAULT_STATUS_RESPONSE) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("024200023C030E0100024C"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.java deleted file mode 100644 index 04191a4f67..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -public class GetVersionCommandTest { - @Test - public void testEncoding() throws DecoderException { - byte[] encoded = new GetVersionCommand.Builder() // - .setSequenceNumber((short) 0) // - .setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt new file mode 100644 index 0000000000..c092142361 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/GetVersionCommandTest.kt @@ -0,0 +1,19 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class GetVersionCommandTest { + + @Test @Throws(DecoderException::class) fun testEncoding() { + val encoded = GetVersionCommand.Builder() // + .setSequenceNumber(0.toShort()) // + .setUniqueId(GetVersionCommand.DEFAULT_UNIQUE_ID) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF00060704FFFFFFFF82B2"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.java deleted file mode 100644 index d137fed93b..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration; -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot; -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTriggerType; -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType; -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType; - -import static org.junit.Assert.assertArrayEquals; - -public class ProgramAlertsCommandTest { - @Test - public void testExpirationAlerts() throws DecoderException { - List configurations = new ArrayList<>(); - configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 420, false, AlertTriggerType.TIME_TRIGGER, (short) 4305, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3)); - configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4725, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4)); - - byte[] encoded = new ProgramAlertsCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 3) // - .setMultiCommandFlag(true) // - .setNonce(1229869870) // - .setAlertConfigurations(configurations) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded); - } - - @Test - public void testLowReservoirAlert() throws DecoderException { - List configurations = new ArrayList<>(); - configurations.add(new AlertConfiguration(AlertSlot.LOW_RESERVOIR, true, (short) 0, false, AlertTriggerType.RESERVOIR_VOLUME_TRIGGER, (short) 200, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX)); - - byte[] encoded = new ProgramAlertsCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 8) // - .setNonce(1229869870) // - .setAlertConfigurations(configurations) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded); - } - - @Test - public void testUserExpirationAlert() throws DecoderException { - List configurations = new ArrayList<>(); - configurations.add(new AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, (short) 0, false, AlertTriggerType.TIME_TRIGGER, (short) 4079, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX2)); - - byte[] encoded = new ProgramAlertsCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 15) // - .setNonce(1229869870) // - .setAlertConfigurations(configurations) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded); - } - - - @Test - public void testLumpOfCoalAlert() throws DecoderException { - List configurations = new ArrayList<>(); - configurations.add(new AlertConfiguration(AlertSlot.EXPIRATION, true, (short) 55, false, AlertTriggerType.TIME_TRIGGER, (short) 5, BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX5)); - - byte[] encoded = new ProgramAlertsCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 10) // - .setMultiCommandFlag(false) // - .setNonce(1229869870) // - .setAlertConfigurations(configurations) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded); - } -} diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt new file mode 100644 index 0000000000..7fca25cfd7 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramAlertsCommandTest.kt @@ -0,0 +1,78 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertConfiguration +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertSlot +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.AlertTriggerType +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepRepetitionType +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test +import java.util.* + +class ProgramAlertsCommandTest { + + @Test @Throws(DecoderException::class) fun testExpirationAlerts() { + val configurations: MutableList = ArrayList() + configurations.add(AlertConfiguration(AlertSlot.EXPIRATION, true, 420.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4305.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX3)) + configurations.add(AlertConfiguration(AlertSlot.EXPIRATION_IMMINENT, true, 0.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4725.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX4)) + + val encoded = ProgramAlertsCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(3.toShort()) // + .setMultiCommandFlag(true) // + .setNonce(1229869870) // + .setAlertConfigurations(configurations) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("024200038C121910494E532E79A410D1050228001275060280F5"), encoded) + } + + @Test @Throws(DecoderException::class) fun testLowReservoirAlert() { + val configurations: MutableList = ArrayList() + configurations.add(AlertConfiguration(AlertSlot.LOW_RESERVOIR, true, 0.toShort(), false, AlertTriggerType.RESERVOIR_VOLUME_TRIGGER, 200.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX)) + + val encoded = ProgramAlertsCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(8.toShort()) // + .setNonce(1229869870) // + .setAlertConfigurations(configurations) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("02420003200C190A494E532E4C0000C801020149"), encoded) + } + + @Test @Throws(DecoderException::class) fun testUserExpirationAlert() { + val configurations: MutableList = ArrayList() + configurations.add(AlertConfiguration(AlertSlot.USER_SET_EXPIRATION, true, 0.toShort(), false, AlertTriggerType.TIME_TRIGGER, 4079.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX2)) + + val encoded = ProgramAlertsCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(15.toShort()) // + .setNonce(1229869870) // + .setAlertConfigurations(configurations) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("024200033C0C190A494E532E38000FEF030203E2"), encoded) + } + + @Test @Throws(DecoderException::class) fun testLumpOfCoalAlert() { + val configurations: MutableList = ArrayList() + configurations.add(AlertConfiguration(AlertSlot.EXPIRATION, true, 55.toShort(), false, AlertTriggerType.TIME_TRIGGER, 5.toShort(), BeepType.FOUR_TIMES_BIP_BEEP, BeepRepetitionType.XXX5)) + + val encoded = ProgramAlertsCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(10.toShort()) // + .setMultiCommandFlag(false) // + .setNonce(1229869870) // + .setAlertConfigurations(configurations) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("02420003280C190A494E532E7837000508020356"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.java deleted file mode 100644 index 16185fdbc4..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Date; -import java.util.List; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram; -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder; - -import static org.junit.Assert.assertArrayEquals; - -public class ProgramBasalCommandTest { - @Test - public void testProgramBasalCommand() throws DecoderException { - List segments = Arrays.asList( - new BasalProgram.Segment((short) 0, (short) 48, 300) - ); - BasalProgram basalProgram = new BasalProgram(segments); - Date date = new Date(2021, 1, 17, 14, 47, 43); - - byte[] encoded = new ProgramBasalCommand.Builder() // - .setUniqueId(37879809) // - .setNonce(1229869870) // - .setSequenceNumber((short) 10) // - .setBasalProgram(basalProgram) // - .setCurrentTime(date) // - .setProgramReminder(new ProgramReminder(false, true, (byte) 0)) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), encoded); - } - -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt new file mode 100644 index 0000000000..ce33402475 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt @@ -0,0 +1,32 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test +import java.util.* + +class ProgramBasalCommandTest { + + @Test @Throws(DecoderException::class) fun testProgramBasalCommand() { + val segments = listOf( + BasalProgram.Segment(0.toShort(), 48.toShort(), 300) + ) + val basalProgram = BasalProgram(segments) + val date = Date(2021, 1, 17, 14, 47, 43) + + val encoded = ProgramBasalCommand.Builder() // + .setUniqueId(37879809) // + .setNonce(1229869870) // + .setSequenceNumber(10.toShort()) // + .setBasalProgram(basalProgram) // + .setCurrentTime(date) // + .setProgramReminder(ProgramReminder(false, true, 0.toByte())) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("0242000128241A12494E532E0005E81D1708000CF01EF01EF01E130E40001593004C4B403840005B8D80827C"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt new file mode 100644 index 0000000000..cd5d06c451 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBeepsCommandTest.kt @@ -0,0 +1,25 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class ProgramBeepsCommandTest { + + @Test @Throws(DecoderException::class) fun testPlayTestBeep() { + val encoded = ProgramBeepsCommand.Builder() // + .setUniqueId(37879810) // + .setSequenceNumber(11.toShort()) // + .setImmediateBeepType(BeepType.FOUR_TIMES_BIP_BEEP) // + .setBasalReminder(ProgramReminder(false, false, 0.toByte())) // + .setTempBasalReminder(ProgramReminder(false, false, 0.toByte())) // + .setBolusReminder(ProgramReminder(false, false, 0.toByte())) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("024200022C061E0402000000800F"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.java deleted file mode 100644 index 2eea08c718..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder; - -import static org.junit.Assert.assertArrayEquals; - -public class ProgramBolusCommandTest { - @Test - public void testProgramBolusCommand() throws DecoderException { - byte[] encoded = new ProgramBolusCommand.Builder() // - .setNumberOfUnits(5) // - .setProgramReminder(new ProgramReminder(false, true, (byte) 0)) // - .setDelayBetweenPulsesInEighthSeconds((byte) 16) // - .setUniqueId(37879809) // - .setSequenceNumber((short) 14) // - .setNonce(1229869870) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), encoded); - } - -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt new file mode 100644 index 0000000000..ce9ea9c24e --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBolusCommandTest.kt @@ -0,0 +1,24 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class ProgramBolusCommandTest { + + @Test @Throws(DecoderException::class) fun testProgramBolusCommand() { + val encoded = ProgramBolusCommand.Builder() // + .setNumberOfUnits(5.0) // + .setProgramReminder(ProgramReminder(false, true, 0.toByte())) // + .setDelayBetweenPulsesInEighthSeconds(16.toByte()) // + .setUniqueId(37879809) // + .setSequenceNumber(14.toShort()) // + .setNonce(1229869870) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("02420001381F1A0E494E532E02010F01064000640064170D4003E800030D4000000000000080F6"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.java deleted file mode 100644 index b622174379..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder; - -import static org.junit.Assert.assertArrayEquals; - -public class ProgramTempBasalCommandTest { - @Test - public void testExtraAlternateSegmentPulseTempBasal() throws DecoderException { - ProgramTempBasalCommand command = new ProgramTempBasalCommand.Builder() // - .setUniqueId(37879809) // - .setNonce(1229869870) // - .setSequenceNumber((short) 15) // - .setRateInUnitsPerHour(5.05d) // - .setDurationInMinutes((short) 60) // - .setProgramReminder(new ProgramReminder(false, true, (byte) 0)) // - .build(); - - assertArrayEquals(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), command.getEncoded()); - } - - @Test - public void testZeroTempBasal() throws DecoderException { - ProgramTempBasalCommand command = new ProgramTempBasalCommand.Builder() // - .setUniqueId(37879809) // - .setNonce(1229869870) // - .setSequenceNumber((short) 7) // - .setRateInUnitsPerHour(0.0) // - .setDurationInMinutes((short) 300) // - .setProgramReminder(new ProgramReminder(true, true, (byte) 0)) // - .build(); - - assertArrayEquals(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000AEB49D20001DE"), command.getEncoded()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt new file mode 100644 index 0000000000..f7875cf2b4 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramTempBasalCommandTest.kt @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.ProgramReminder +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class ProgramTempBasalCommandTest { + + @Test @Throws(DecoderException::class) fun testExtraAlternateSegmentPulseTempBasal() { + val command = ProgramTempBasalCommand.Builder() // + .setUniqueId(37879809) // + .setNonce(1229869870) // + .setSequenceNumber(15.toShort()) // + .setRateInUnitsPerHour(5.05) // + .setDurationInMinutes(60.toShort()) // + .setProgramReminder(ProgramReminder(false, true, 0.toByte())) // + .build() + + Assert.assertArrayEquals(Hex.decodeHex("024200013C201A0E494E532E01011102384000321832160E400003F20036634403F20036634482A6"), command.encoded) + } + + @Test @Throws(DecoderException::class) fun testZeroTempBasal() { + val command = ProgramTempBasalCommand.Builder() // + .setUniqueId(37879809) // + .setNonce(1229869870) // + .setSequenceNumber(7.toShort()) // + .setRateInUnitsPerHour(0.0) // + .setDurationInMinutes(300.toShort()) // + .setProgramReminder(ProgramReminder(true, true, 0.toByte())) // + .build() + + Assert.assertArrayEquals(Hex.decodeHex("024200011C201A0E494E532E0100820A384000009000160EC000000A6B49D200000AEB49D20001DE"), command.encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.java deleted file mode 100644 index 7965ebe0a1..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import java.util.Date; - -import static org.junit.Assert.assertArrayEquals; - -public class SetUniqueIdCommandTest { - @Test - public void testEncoding() throws DecoderException { - @SuppressWarnings("deprecation") - byte[] encoded = new SetUniqueIdCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 6) // - .setLotNumber(135556289) // - .setPodSequenceNumber(681767) // - .setInitializationTime(new Date(2021, 1, 10, 14, 41)) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt new file mode 100644 index 0000000000..4dda5f9a38 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SetUniqueIdCommandTest.kt @@ -0,0 +1,23 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test +import java.util.* + +class SetUniqueIdCommandTest { + + @Test @Throws(DecoderException::class) fun testEncoding() { + val encoded = SetUniqueIdCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(6.toShort()) // + .setLotNumber(135556289) // + .setPodSequenceNumber(681767) // + .setInitializationTime(Date(2021, 1, 10, 14, 41)) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("FFFFFFFF18150313024200031404020A150E2908146CC1000A67278344"), encoded) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.java deleted file mode 100644 index a8447ed558..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import static org.junit.Assert.assertArrayEquals; - -public class SilenceAlertsCommandTest { - @Test - public void testSilenceLowReservoirAlert() throws DecoderException { - byte[] encoded = new SilenceAlertsCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 1) // - .setNonce(1229869870) // - .setSilenceLowReservoirAlert(true) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded); - } - - // TODO capture more silence alerts commands -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt new file mode 100644 index 0000000000..f901594225 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/SilenceAlertsCommandTest.kt @@ -0,0 +1,23 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class SilenceAlertsCommandTest { + + @Test @Throws(DecoderException::class) fun testSilenceLowReservoirAlert() { + val encoded = SilenceAlertsCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(1.toShort()) // + .setNonce(1229869870) // + .setSilenceLowReservoirAlert(true) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("0242000304071105494E532E1081CE"), encoded) + } + + // TODO capture more silence alerts commands +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.java deleted file mode 100644 index 08576996bb..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType; - -import static org.junit.Assert.assertArrayEquals; - -public class StopDeliveryCommandTest { - @Test - public void testStopTempBasal() throws DecoderException { - byte[] encoded = new StopDeliveryCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 0) // - .setNonce(1229869870) // - .setDeliveryType(StopDeliveryCommand.DeliveryType.TEMP_BASAL) // - .setBeepType(BeepType.LONG_SINGLE_BEEP) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded); - } - - @Test - public void testSuspendDelivery() throws DecoderException { - byte[] encoded = new StopDeliveryCommand.Builder() // - .setUniqueId(37879811) // - .setSequenceNumber((short) 2) // - .setNonce(1229869870) // - .setDeliveryType(StopDeliveryCommand.DeliveryType.ALL) // - .setBeepType(BeepType.SILENT) // - .build() // - .getEncoded(); - - assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded); - } - - // TODO test cancel bolus -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt new file mode 100644 index 0000000000..a9463e1785 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/StopDeliveryCommandTest.kt @@ -0,0 +1,38 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command + +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BeepType +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class StopDeliveryCommandTest { + + @Test @Throws(DecoderException::class) fun testStopTempBasal() { + val encoded = StopDeliveryCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(0.toShort()) // + .setNonce(1229869870) // + .setDeliveryType(StopDeliveryCommand.DeliveryType.TEMP_BASAL) // + .setBeepType(BeepType.LONG_SINGLE_BEEP) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("0242000300071F05494E532E6201B1"), encoded) + } + + @Test @Throws(DecoderException::class) fun testSuspendDelivery() { + val encoded = StopDeliveryCommand.Builder() // + .setUniqueId(37879811) // + .setSequenceNumber(2.toShort()) // + .setNonce(1229869870) // + .setDeliveryType(StopDeliveryCommand.DeliveryType.ALL) // + .setBeepType(BeepType.SILENT) // + .build() // + .encoded + + Assert.assertArrayEquals(Hex.decodeHex("0242000308071F05494E532E078287"), encoded) + } + + // TODO test cancel bolus +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.java deleted file mode 100644 index 892f22cdb2..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -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 static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; - -public class AlarmStatusResponseTest { - @Test - public void testValidResponse() throws DecoderException { - byte[] encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A"); - AlarmStatusResponse response = new AlarmStatusResponse(encoded); - - assertArrayEquals(encoded, response.getEncoded()); - assertNotSame(encoded, response.getEncoded()); - assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.getResponseType()); - assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.getValue(), response.getMessageType()); - assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS, response.getStatusResponseType()); - assertEquals(ResponseType.AdditionalStatusResponseType.ALARM_STATUS.getValue(), response.getAdditionalStatusResponseType()); - assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus()); - assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus()); - assertEquals((short) 0, response.getBolusPulsesRemaining()); - assertEquals((short) 5, response.getSequenceNumberOfLastProgrammingCommand()); - assertEquals((short) 445, response.getTotalPulsesDelivered()); - assertEquals(AlarmType.NONE, response.getAlarmType()); - assertEquals((short) 0, response.getAlarmTime()); - assertEquals((short) 1023, response.getReservoirPulsesRemaining()); - assertEquals((short) 405, response.getMinutesSinceActivation()); - assertFalse(response.isAlert0Active()); - assertFalse(response.isAlert1Active()); - assertFalse(response.isAlert2Active()); - assertFalse(response.isAlert3Active()); - assertFalse(response.isAlert4Active()); - assertFalse(response.isAlert5Active()); - assertFalse(response.isAlert6Active()); - assertFalse(response.isAlert7Active()); - assertFalse(response.isOcclusionAlarm()); - assertFalse(response.isPulseInfoInvalid()); - assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred()); - assertFalse(response.isImmediateBolusWhenAlarmOccurred()); - assertEquals((byte) 0x00, response.getOcclusionType()); - assertFalse(response.isOccurredWhenFetchingImmediateBolusActiveInformation()); - assertEquals(0, response.getRssi()); - assertEquals(0, response.getReceiverLowerGain()); - assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred2()); - assertEquals((short) 26378, response.getReturnAddressOfPodAlarmHandlerCaller()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt new file mode 100644 index 0000000000..1621faccb2 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/AlarmStatusResponseTest.kt @@ -0,0 +1,51 @@ +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.DeliveryStatus +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class AlarmStatusResponseTest { + + @Test @Throws(DecoderException::class) fun testValidResponse() { + val encoded = Hex.decodeHex("021602080100000501BD00000003FF01950000000000670A") + val response = AlarmStatusResponse(encoded) + + Assert.assertArrayEquals(encoded, response.encoded) + Assert.assertNotSame(encoded, response.encoded) + Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE, response.responseType) + Assert.assertEquals(ResponseType.ADDITIONAL_STATUS_RESPONSE.value, response.getMessageType()) + Assert.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS, response.statusResponseType) + Assert.assertEquals(ResponseType.StatusResponseType.ALARM_STATUS.value, response.getAdditionalStatusResponseType()) + Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus()) + Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus()) + Assert.assertEquals(0.toShort(), response.getBolusPulsesRemaining()) + Assert.assertEquals(5.toShort(), response.getSequenceNumberOfLastProgrammingCommand()) + Assert.assertEquals(445.toShort(), response.getTotalPulsesDelivered()) + Assert.assertEquals(AlarmType.NONE, response.getAlarmType()) + Assert.assertEquals(0.toShort(), response.getAlarmTime()) + Assert.assertEquals(1023.toShort(), response.getReservoirPulsesRemaining()) + Assert.assertEquals(405.toShort(), response.getMinutesSinceActivation()) + Assert.assertFalse(response.isAlert0Active()) + Assert.assertFalse(response.isAlert1Active()) + Assert.assertFalse(response.isAlert2Active()) + Assert.assertFalse(response.isAlert3Active()) + Assert.assertFalse(response.isAlert4Active()) + Assert.assertFalse(response.isAlert5Active()) + Assert.assertFalse(response.isAlert6Active()) + Assert.assertFalse(response.isAlert7Active()) + Assert.assertFalse(response.isOcclusionAlarm()) + Assert.assertFalse(response.isPulseInfoInvalid()) + Assert.assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred()) + Assert.assertFalse(response.isImmediateBolusWhenAlarmOccurred()) + Assert.assertEquals(0x00.toByte(), response.getOcclusionType()) + Assert.assertFalse(response.isOccurredWhenFetchingImmediateBolusActiveInformation()) + Assert.assertEquals(0.toShort(), response.getRssi()) + Assert.assertEquals(0.toShort(), response.getReceiverLowerGain()) + Assert.assertEquals(PodStatus.UNINITIALIZED, response.getPodStatusWhenAlarmOccurred2()) + Assert.assertEquals(26378.toShort(), response.getReturnAddressOfPodAlarmHandlerCaller()) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.java deleted file mode 100644 index 2e3ddbd7c1..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -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 static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; - -public class DefaultStatusResponseTest { - @Test - public void testValidResponse() throws DecoderException { - byte[] encoded = Hex.decodeHex("1D1800A02800000463FF"); - DefaultStatusResponse response = new DefaultStatusResponse(encoded); - - assertArrayEquals(encoded, response.getEncoded()); - assertNotSame(encoded, response.getEncoded()); - assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.getResponseType()); - assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.getValue(), response.getMessageType()); - assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus()); - assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus()); - assertEquals((short) 320, response.getTotalPulsesDelivered()); - assertEquals((short) 5, response.getSequenceNumberOfLastProgrammingCommand()); - assertEquals((short) 0, response.getBolusPulsesRemaining()); - assertFalse(response.isOcclusionAlertActive()); - assertFalse(response.isAlert1Active()); - assertFalse(response.isAlert2Active()); - assertFalse(response.isAlert3Active()); - assertFalse(response.isAlert4Active()); - assertFalse(response.isAlert5Active()); - assertFalse(response.isAlert6Active()); - assertFalse(response.isAlert7Active()); - assertEquals((short) 280, response.getMinutesSinceActivation()); - assertEquals((short) 1023, response.getReservoirPulsesRemaining()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt new file mode 100644 index 0000000000..6ccbdfd13e --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponseTest.kt @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response + +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 +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class DefaultStatusResponseTest { + + @Test @Throws(DecoderException::class) fun testValidResponse() { + val encoded = Hex.decodeHex("1D1800A02800000463FF") + val response = DefaultStatusResponse(encoded) + Assert.assertArrayEquals(encoded, response.encoded) + Assert.assertNotSame(encoded, response.encoded) + Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE, response.responseType) + Assert.assertEquals(ResponseType.DEFAULT_STATUS_RESPONSE.value, response.getMessageType()) + Assert.assertEquals(DeliveryStatus.BASAL_ACTIVE, response.getDeliveryStatus()) + Assert.assertEquals(PodStatus.RUNNING_ABOVE_MIN_VOLUME, response.getPodStatus()) + Assert.assertEquals(320.toShort(), response.getTotalPulsesDelivered()) + Assert.assertEquals(5.toShort(), response.getSequenceNumberOfLastProgrammingCommand()) + Assert.assertEquals(0.toShort(), response.getBolusPulsesRemaining()) + Assert.assertFalse(response.isOcclusionAlertActive()) + Assert.assertFalse(response.isAlert1Active()) + Assert.assertFalse(response.isAlert2Active()) + Assert.assertFalse(response.isAlert3Active()) + Assert.assertFalse(response.isAlert4Active()) + Assert.assertFalse(response.isAlert5Active()) + Assert.assertFalse(response.isAlert6Active()) + Assert.assertFalse(response.isAlert7Active()) + Assert.assertEquals(280.toShort(), response.getMinutesSinceActivation()) + Assert.assertEquals(1023.toShort(), response.getReservoirPulsesRemaining()) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.java deleted file mode 100644 index 06937a0e92..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -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 static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - -public class NakResponseTest { - @Test - public void testValidResponse() throws DecoderException { - byte[] encoded = Hex.decodeHex("0603070009"); - NakResponse response = new NakResponse(encoded); - - assertArrayEquals(encoded, response.getEncoded()); - assertNotSame(encoded, response.getEncoded()); - assertEquals(ResponseType.NAK_RESPONSE, response.getResponseType()); - assertEquals(ResponseType.NAK_RESPONSE.getValue(), response.getMessageType()); - assertEquals(NakErrorType.ILLEGAL_PARAM, response.getNakErrorType()); - assertEquals(AlarmType.NONE, response.getAlarmType()); - assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.getPodStatus()); - assertEquals((byte) 0x00, response.getSecurityNakSyncCount()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt new file mode 100644 index 0000000000..c4dc703f79 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/NakResponseTest.kt @@ -0,0 +1,27 @@ +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 info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.ResponseType +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class NakResponseTest { + + @Test @Throws(DecoderException::class) fun testValidResponse() { + val encoded = Hex.decodeHex("0603070009") + val response = NakResponse(encoded) + + Assert.assertArrayEquals(encoded, response.encoded) + Assert.assertNotSame(encoded, response.encoded) + Assert.assertEquals(ResponseType.NAK_RESPONSE, response.responseType) + Assert.assertEquals(ResponseType.NAK_RESPONSE.value, response.getMessageType()) + Assert.assertEquals(NakErrorType.ILLEGAL_PARAM, response.getNakErrorType()) + Assert.assertEquals(AlarmType.NONE, response.getAlarmType()) + Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.getPodStatus()) + Assert.assertEquals(0x00.toShort(), response.getSecurityNakSyncCount()) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.java deleted file mode 100644 index 1de262db9d..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - -public class SetUniqueIdResponseTest { - @Test - public void testValidResponse() throws DecoderException { - byte[] encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001"); - SetUniqueIdResponse response = new SetUniqueIdResponse(encoded); - - assertArrayEquals(encoded, response.getEncoded()); - assertNotSame(encoded, response.getEncoded()); - assertEquals(ResponseType.ACTIVATION_RESPONSE, response.getResponseType()); - assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.getActivationResponseType()); - - assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType()); - assertEquals(27, response.getMessageLength()); - assertEquals(5000, response.getPulseVolumeInTenThousandthMicroLiter()); - assertEquals(16, response.getDeliveryRate()); - assertEquals(8, response.getPrimeRate()); - assertEquals(52, response.getNumberOfEngagingClutchDrivePulses()); - assertEquals(10, response.getNumberOfPrimePulses()); - assertEquals(80, response.getPodExpirationTimeInHours()); - assertEquals(4, response.getFirmwareVersionMajor()); - assertEquals(10, response.getFirmwareVersionMinor()); - assertEquals(0, response.getFirmwareVersionInterim()); - assertEquals(1, response.getBleVersionMajor()); - assertEquals(3, response.getBleVersionMinor()); - assertEquals(0, response.getBleVersionInterim()); - assertEquals(4, response.getProductId()); - assertEquals(PodStatus.UID_SET, response.getPodStatus()); - assertEquals(135556289L, response.getLotNumber()); - assertEquals(611540L, response.getPodSequenceNumber()); - assertEquals(37879809L, response.getUniqueIdReceivedInCommand()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt new file mode 100644 index 0000000000..fa0d1dac73 --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/SetUniqueIdResponseTest.kt @@ -0,0 +1,40 @@ +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 +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class SetUniqueIdResponseTest { + + @Test @Throws(DecoderException::class) fun testValidResponse() { + val encoded = Hex.decodeHex("011B13881008340A50040A00010300040308146CC1000954D402420001") + val response = SetUniqueIdResponse(encoded) + + Assert.assertArrayEquals(encoded, response.encoded) + Assert.assertNotSame(encoded, response.encoded) + Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) + Assert.assertEquals(ResponseType.ActivationResponseType.SET_UNIQUE_ID_RESPONSE, response.activationResponseType) + Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.getMessageType()) + Assert.assertEquals(27.toShort(), response.getMessageLength()) + Assert.assertEquals(5000.toShort(), response.getPulseVolumeInTenThousandthMicroLiter()) + Assert.assertEquals(16.toShort(), response.getDeliveryRate()) + Assert.assertEquals(8.toShort(), response.getPrimeRate()) + Assert.assertEquals(52.toShort(), response.getNumberOfEngagingClutchDrivePulses()) + Assert.assertEquals(10.toShort(), response.getNumberOfPrimePulses()) + Assert.assertEquals(80.toShort(), response.getPodExpirationTimeInHours()) + Assert.assertEquals(4.toShort(), response.getFirmwareVersionMajor()) + Assert.assertEquals(10.toShort(), response.getFirmwareVersionMinor()) + Assert.assertEquals(0.toShort(), response.getFirmwareVersionInterim()) + Assert.assertEquals(1.toShort(), response.getBleVersionMajor()) + Assert.assertEquals(3.toShort(), response.getBleVersionMinor()) + Assert.assertEquals(0.toShort(), response.getBleVersionInterim()) + Assert.assertEquals(4.toShort(), response.getProductId()) + Assert.assertEquals(PodStatus.UID_SET, response.getPodStatus()) + Assert.assertEquals(135556289L, response.getLotNumber()) + Assert.assertEquals(611540L, response.getPodSequenceNumber()) + Assert.assertEquals(37879809L, response.getUniqueIdReceivedInCommand()) + } +} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.java b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.java deleted file mode 100644 index c88142a715..0000000000 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.junit.Test; - -import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodStatus; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - -public class VersionResponseTest { - - @Test - public void testValidResponse() throws DecoderException { - byte[] encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF"); - VersionResponse response = new VersionResponse(encoded); - - assertArrayEquals(encoded, response.getEncoded()); - assertNotSame(encoded, response.getEncoded()); - assertEquals(ResponseType.ACTIVATION_RESPONSE, response.getResponseType()); - assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.getActivationResponseType()); - - assertEquals(ResponseType.ACTIVATION_RESPONSE.getValue(), response.getMessageType()); - assertEquals(21, response.getMessageLength()); - assertEquals(4, response.getFirmwareVersionMajor()); - assertEquals(10, response.getFirmwareVersionMinor()); - assertEquals(0, response.getFirmwareVersionInterim()); - assertEquals(1, response.getBleVersionMajor()); - assertEquals(3, response.getBleVersionMinor()); - assertEquals(0, response.getBleVersionInterim()); - assertEquals(4, response.getProductId()); - assertEquals(PodStatus.FILLED, response.getPodStatus()); - assertEquals(135556289, response.getLotNumber()); - assertEquals(611540, response.getPodSequenceNumber()); - assertEquals(0L, response.getRssi()); - assertEquals(0L, response.getReceiverLowerGain()); - assertEquals(4294967295L, response.getUniqueIdReceivedInCommand()); - } -} \ No newline at end of file diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt new file mode 100644 index 0000000000..32612070fd --- /dev/null +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/VersionResponseTest.kt @@ -0,0 +1,36 @@ +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 +import org.apache.commons.codec.DecoderException +import org.apache.commons.codec.binary.Hex +import org.junit.Assert +import org.junit.Test + +class VersionResponseTest { + + @Test @Throws(DecoderException::class) fun testValidResponse() { + val encoded = Hex.decodeHex("0115040A00010300040208146CC1000954D400FFFFFFFF") + val response = VersionResponse(encoded) + + Assert.assertArrayEquals(encoded, response.encoded) + Assert.assertNotSame(encoded, response.encoded) + Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE, response.responseType) + Assert.assertEquals(ResponseType.ActivationResponseType.GET_VERSION_RESPONSE, response.activationResponseType) + Assert.assertEquals(ResponseType.ACTIVATION_RESPONSE.value, response.getMessageType()) + Assert.assertEquals(21.toShort(), response.getMessageLength()) + Assert.assertEquals(4.toShort(), response.getFirmwareVersionMajor()) + Assert.assertEquals(10.toShort(), response.getFirmwareVersionMinor()) + Assert.assertEquals(0.toShort(), response.getFirmwareVersionInterim()) + Assert.assertEquals(1.toShort(), response.getBleVersionMajor()) + Assert.assertEquals(3.toShort(), response.getBleVersionMinor()) + Assert.assertEquals(0.toShort(), response.getBleVersionInterim()) + Assert.assertEquals(4.toShort(), response.getProductId()) + Assert.assertEquals(PodStatus.FILLED, response.getPodStatus()) + Assert.assertEquals(135556289L, response.getLotNumber()) + Assert.assertEquals(611540L, response.getPodSequenceNumber()) + Assert.assertEquals(0.toByte(), response.getRssi()) + Assert.assertEquals(0.toByte(), response.getReceiverLowerGain()) + Assert.assertEquals(4294967295L, response.getUniqueIdReceivedInCommand()) + } +} \ No newline at end of file