fix DanaR reading history

This commit is contained in:
Milos Kozak 2020-07-01 22:31:35 +02:00
parent a08c1d5269
commit 8cf2d3aeb1

View file

@ -17,8 +17,6 @@ open class MsgHistoryAll(
override fun handleMessage(bytes: ByteArray) {
val recordCode = intFromBuff(bytes, 0, 1).toByte()
val date = dateFromBuff(bytes, 1) // 3 bytes
val datetime = dateTimeFromBuff(bytes, 1) // 5 bytes
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
val dailyBasal = intFromBuff(bytes, 4, 2) * 0.01
val dailyBolus = intFromBuff(bytes, 6, 2) * 0.01
//val paramByte5 = intFromBuff(bytes, 4, 1).toByte()
@ -32,6 +30,7 @@ open class MsgHistoryAll(
var messageType = ""
when (recordCode) {
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_BOLUS -> {
val datetime = dateTimeFromBuff(bytes, 1) // 5 bytes
danaRHistoryRecord.recordDate = datetime
when (0xF0 and paramByte8.toInt()) {
0xA0 -> {
@ -69,48 +68,56 @@ open class MsgHistoryAll(
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_PRIME -> {
messageType += "prime"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value * 0.01
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_ERROR -> {
messageType += "error"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value * 0.01
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_REFILL -> {
messageType += "refill"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value * 0.01
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_BASALHOUR -> {
messageType += "basal hour"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value * 0.01
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_TB -> {
messageType += "tb"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value * 0.01
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_GLUCOSE -> {
messageType += "glucose"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_CARBO -> {
messageType += "carbo"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
danaRHistoryRecord.recordValue = value
}
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_ALARM -> {
messageType += "alarm"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
var strAlarm = "None"
when (paramByte8.toInt()) {
@ -125,6 +132,7 @@ open class MsgHistoryAll(
info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_SUSPEND -> {
messageType += "suspend"
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
danaRHistoryRecord.recordDate = datetimewihtsec
var strRecordValue = "Off"
if (paramByte8.toInt() == 79) strRecordValue = "On"