This commit is contained in:
Milos Kozak 2022-04-04 10:22:11 +02:00
parent c542b00585
commit 4fb03fb4de
2 changed files with 17 additions and 17 deletions

View file

@ -42,8 +42,8 @@ class MsgHistoryEventsV2 constructor(
messageBuffer = arrayListOf() messageBuffer = arrayListOf()
} }
override fun handleMessage(data: ByteArray) { override fun handleMessage(bytes: ByteArray) {
val recordCode = intFromBuff(data, 0, 1).toByte() val recordCode = intFromBuff(bytes, 0, 1).toByte()
// Last record // Last record
if (recordCode == 0xFF.toByte()) { if (recordCode == 0xFF.toByte()) {
aapsLogger.debug(LTag.PUMPCOMM, "Last record received") aapsLogger.debug(LTag.PUMPCOMM, "Last record received")
@ -52,7 +52,7 @@ class MsgHistoryEventsV2 constructor(
val sorted = array.sortedArrayWith { s1: ByteArray, s2: ByteArray -> (dateTime(s1) - dateTime(s2)).toInt() } val sorted = array.sortedArrayWith { s1: ByteArray, s2: ByteArray -> (dateTime(s1) - dateTime(s2)).toInt() }
for (message in sorted) processMessage(message) for (message in sorted) processMessage(message)
danaPump.historyDoneReceived = true danaPump.historyDoneReceived = true
} else messageBuffer.add(data) } else messageBuffer.add(bytes)
} }
fun dateTime(data: ByteArray): Long = fun dateTime(data: ByteArray): Long =

View file

@ -13,21 +13,21 @@ class MsgSettingUserOptions(
aapsLogger.debug(LTag.PUMPCOMM, "New message") aapsLogger.debug(LTag.PUMPCOMM, "New message")
} }
override fun handleMessage(packet: ByteArray) { override fun handleMessage(bytes: ByteArray) {
val bytes = getDataBytes(packet, packet.size - 10) val data = getDataBytes(bytes, bytes.size - 10)
danaPump.userOptionsFromPump = bytes.copyOf(bytes.size) // saving pumpDataBytes to use it in MsgSetUserOptions danaPump.userOptionsFromPump = data.copyOf(data.size) // saving pumpDataBytes to use it in MsgSetUserOptions
for (pos in bytes.indices) { for (pos in data.indices) {
aapsLogger.debug(LTag.PUMPCOMM, "[" + pos + "]" + bytes[pos]) aapsLogger.debug(LTag.PUMPCOMM, "[" + pos + "]" + data[pos])
} }
danaPump.timeDisplayType24 = bytes[0].toInt() == 0 // 0 -> 24h 1 -> 12h danaPump.timeDisplayType24 = data[0].toInt() == 0 // 0 -> 24h 1 -> 12h
danaPump.buttonScrollOnOff = bytes[1] == 1.toByte() // 1 -> ON, 0-> OFF danaPump.buttonScrollOnOff = data[1] == 1.toByte() // 1 -> ON, 0-> OFF
danaPump.beepAndAlarm = bytes[2].toInt() // 1 -> Sound on alarm 2-> Vibrate on alarm 3-> Both on alarm 5-> Sound + beep 6-> vibrate + beep 7-> both + beep Beep adds 4 danaPump.beepAndAlarm = data[2].toInt() // 1 -> Sound on alarm 2-> Vibrate on alarm 3-> Both on alarm 5-> Sound + beep 6-> vibrate + beep 7-> both + beep Beep adds 4
danaPump.lcdOnTimeSec = bytes[3].toInt() danaPump.lcdOnTimeSec = data[3].toInt()
danaPump.backlightOnTimeSec = bytes[4].toInt() danaPump.backlightOnTimeSec = data[4].toInt()
danaPump.selectedLanguage = bytes[5].toInt() // on DanaRv2 is that needed ? danaPump.selectedLanguage = data[5].toInt() // on DanaRv2 is that needed ?
danaPump.units = bytes[8].toInt() danaPump.units = data[8].toInt()
danaPump.shutdownHour = bytes[9].toInt() danaPump.shutdownHour = data[9].toInt()
danaPump.lowReservoirRate = bytes[32].toInt() danaPump.lowReservoirRate = data[32].toInt()
/* int selectableLanguage1 = bytes[10]; /* int selectableLanguage1 = bytes[10];
int selectableLanguage2 = bytes[11]; int selectableLanguage2 = bytes[11];
int selectableLanguage3 = bytes[12]; int selectableLanguage3 = bytes[12];