diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt index 6cace72c5f..fcc84f1314 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRFragment.kt @@ -210,12 +210,7 @@ class DanaRFragment : DaggerFragment() { danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}" SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0) danar_iob.text = resourceHelper.gs(R.string.formatinsulinunits, pump.iob) - if (pump.btModel != 0 || pump.protocol != 0 || pump.productCode != 0) { - danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.btModel, pump.protocol, pump.productCode) - } else { - @Suppress("SetTextI18n") - danar_firmware.text = "OLD" - } + danar_firmware.text = resourceHelper.gs(R.string.danar_model, pump.modelFriendlyName(), pump.hwModel, pump.protocol, pump.productCode) danar_basalstep.text = pump.basalStep.toString() danar_bolusstep.text = pump.bolusStep.toString() danar_serialnumber.text = pump.serialNumber @@ -229,7 +224,7 @@ class DanaRFragment : DaggerFragment() { //hide user options button if not an RS pump or old firmware // also excludes pump with model 03 because of untested error val isKorean = danaRKoreanPlugin.isEnabled(PluginType.PUMP) - if (isKorean || danar_firmware.text === "OLD" || pump.btModel == 3) { + if (isKorean || pump.hwModel == 0 || pump.hwModel == 3) { danar_user_options.visibility = View.GONE } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt index eb5bb627fc..213efac04d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPump.kt @@ -51,7 +51,7 @@ class DanaRPump @Inject constructor( var isNewPump = true // R only , providing model info var password = -1 // R, RSv1 var pumpTime: Long = 0 - var btModel = 0 + var hwModel = 0 var protocol = 0 var productCode = 0 var errorState: ErrorState = ErrorState.NONE @@ -227,6 +227,21 @@ class DanaRPump @Inject constructor( lastSettingsRead = 0 } + fun modelFriendlyName(): String = + when (hwModel) { + 0x01 -> "DanaR Korean" + 0x03 -> + if (protocol == 0x00) "DanaR old" + else if (protocol == 0x02) "DanaR v2" + else "DanaR" // 0x01 and 0x03 known + 0x05 -> + if (protocol < 10) "DanaRS" + else "DanaRS v3" + 0x06 -> "DanaRS Korean" + 0x07 -> "Dana-i" + else -> "Unknown Dana pump" + } + companion object { const val UNITS_MGDL = 0 const val UNITS_MMOL = 1 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt index 3cc8701a38..f573ef0475 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValue.kt @@ -19,14 +19,14 @@ class MsgCheckValue( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { + if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) { danaRPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt index 412d13cf3d..1742c4b1dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRKorean/comm/MsgCheckValue_k.kt @@ -21,14 +21,14 @@ class MsgCheckValue_k( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.DOMESTIC_MODEL) { + if (danaRPump.hwModel != DanaRPump.DOMESTIC_MODEL) { danaRKoreanPlugin.disconnect("Wrong Model") aapsLogger.debug(LTag.PUMPCOMM, "Wrong model selected") } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt index 5646c6f370..be57043e89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_Pump_Check.kt @@ -30,14 +30,14 @@ class DanaRS_Packet_General_Get_Pump_Check( failed = false var dataIndex = DATA_START var dataSize = 1 - danaRPump.btModel = byteArrayToInt(getBytes(data, dataIndex, dataSize)) + danaRPump.hwModel = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.protocol = byteArrayToInt(getBytes(data, dataIndex, dataSize)) dataIndex += dataSize dataSize = 1 danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize)) - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) if (danaRPump.productCode < 2) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt index 87628c0d1a..7d0b2b5e53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2.kt @@ -38,10 +38,10 @@ class MsgCheckValue_v2( override fun handleMessage(bytes: ByteArray) { danaRPump.isNewPump = true aapsLogger.debug(LTag.PUMPCOMM, "New firmware confirmed") - danaRPump.btModel = intFromBuff(bytes, 0, 1) + danaRPump.hwModel = intFromBuff(bytes, 0, 1) danaRPump.protocol = intFromBuff(bytes, 1, 1) danaRPump.productCode = intFromBuff(bytes, 2, 1) - if (danaRPump.btModel != DanaRPump.EXPORT_MODEL) { + if (danaRPump.hwModel != DanaRPump.EXPORT_MODEL) { danaRPump.reset() val notification = Notification(Notification.WRONG_DRIVER, resourceHelper.gs(R.string.pumpdrivercorrected), Notification.NORMAL) rxBus.send(EventNewNotification(notification)) @@ -74,7 +74,7 @@ class MsgCheckValue_v2( commandQueue.readStatus("PumpDriverChange", null) // force new connection return } - aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.btModel)) + aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.hwModel)) aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol)) aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode)) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3ac901f44f..86b7c02cbc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -485,7 +485,7 @@ Useful when data from unfiltered sources like xDrip gets noisy. Advanced Settings key_advancedsettings - Model: %1$02X Protocol: %2$02X Code: %3$02X + %1$s\nModel: %2$02X\nProtocol: %3$02X\nCode: %4$02X Profile Default value: 3 This is a key OpenAPS safety cap. What this does is limit your basals to be 3x (in this people) your biggest basal rate. You likely will not need to change this, but you should be aware that’s what is discussed about “3x max daily; 4x current” for safety caps. Default value: 4 This is the other half of the key OpenAPS safety caps, and the other half of “3x max daily; 4x current” of the safety caps. This means your basal, regardless of max basal set on your pump, cannot be any higher than this number times the current level of your basal. This is to prevent people from getting into dangerous territory by setting excessively high max basals before understanding how the algorithm works. Again, the default is 4x; most people will never need to adjust this and are instead more likely to need to adjust other settings if they feel like they are “running into” this safety cap. diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt index b9d959c631..2b5058241d 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgCheckValueTest.kt @@ -20,6 +20,6 @@ class MsgCheckValueTest : DanaRTestBase() { val array = ByteArray(100) putByteToArray(array, 0, DanaRPump.EXPORT_MODEL.toByte()) packet.handleMessage(array) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel) } } \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt index 77bf756890..4bd8ad6e57 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgCheckValue_v2Test.kt @@ -33,6 +33,6 @@ class MsgCheckValue_v2Test : DanaRTestBase() { val packet = MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue) // test message decoding packet.handleMessage(createArray(34, 3.toByte())) - Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.btModel) + Assert.assertEquals(DanaRPump.EXPORT_MODEL, danaRPump.hwModel) } } \ No newline at end of file