From 03b051eb8c7b5f3d8fcbf1098e8807f9caf8486a Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 5 Oct 2021 22:54:35 +0200 Subject: [PATCH] fix remaning units --- .../pod/response/DefaultStatusResponse.kt | 2 +- .../pod/response/DefaultStatusResponseTest.kt | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt index 584349de78..3017a5ed49 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/response/DefaultStatusResponse.kt @@ -24,7 +24,7 @@ class DefaultStatusResponse( AlertUtil.decodeAlertSet((encoded[6].toInt() and 0xff shl 1 or (encoded[7] ushr 7)).toByte()) val minutesSinceActivation: Short = (encoded[7] and 0x7f shl 6 or (encoded[8].toInt() and 0xff ushr 2 and 0x3f)).toShort() - val reservoirPulsesRemaining: Short = (encoded[8] shl 8 or encoded[9].toInt() and 0x3ff).toShort() + val reservoirPulsesRemaining: Short = (encoded[8] shl 8 or (encoded[9].toInt() and 0xff) and 0x3ff).toShort() override fun toString(): String { return "DefaultStatusResponse(" + 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 index bcce591db4..20341a9a67 100644 --- 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 @@ -27,7 +27,7 @@ class DefaultStatusResponseTest { } /** - * response (hex) 08202EAA0C0A1D1905281000004387D3039A + * response (hex) 1D1905281000004387D3039A Status response: 29 Pod status: RUNNING_BELOW_MIN_VOLUME Basal active: true @@ -66,7 +66,7 @@ class DefaultStatusResponseTest { } /** - * response (hex) 08202EAA080A1D180519C00E0039A7FF8085 + * response (hex) 1D180519C00E0039A7FF8085 Status response: 29 Pod status: RUNNING_ABOVE_MIN_VOLUME Basal active: true @@ -103,4 +103,34 @@ class DefaultStatusResponseTest { Assert.assertEquals(1023.toShort(), response.reservoirPulsesRemaining) Assert.assertEquals(2611.toShort(), response.totalPulsesDelivered) } + + /** response (hex) 1D990714201F0042ED8801DE + Status response: 29 + Pod status: RUNNING_BELOW_MIN_VOLUME + Basal active: true + Temp Basal active: false + Immediate bolus active: false + Extended bolus active: true + Bolus pulses remaining: 31 + sequence number of last programing command: 4 + Total full pulses delivered: 3624 + Full reservoir pulses remaining: 392 + Time since activation: 4283 + */ + @Test @Throws(DecoderException::class) fun testValidResponseBolusPulsesRemaining2() { + val encoded = Hex.decodeHex("1D990714201F0042ED8801DE") + 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.messageType) + Assert.assertEquals(DeliveryStatus.UNKNOWN, response.deliveryStatus) // Extended bolus active + Assert.assertEquals(PodStatus.RUNNING_BELOW_MIN_VOLUME, response.podStatus) + Assert.assertEquals(4.toShort(), response.sequenceNumberOfLastProgrammingCommand) + Assert.assertEquals(31.toShort(), response.bolusPulsesRemaining) + Assert.assertEquals(0, response.activeAlerts.size) + Assert.assertEquals(4283.toShort(), response.minutesSinceActivation) + Assert.assertEquals(392.toShort(), response.reservoirPulsesRemaining) + Assert.assertEquals(3624.toShort(), response.totalPulsesDelivered) + } }