fix issue #6 - decoding batterystatusrxmessage for Dexcom g5 and g6

This commit is contained in:
Johan Degraeve 2019-07-27 00:09:46 +02:00
parent 7690914dcc
commit 284ea2f3c9
1 changed files with 7 additions and 3 deletions

View File

@ -10,7 +10,7 @@ struct BatteryStatusRxMessage: TransmitterRxMessage {
let temperature:Int
init?(data: Data) {
guard data.count >= 12 && data.isCRCValid else {
guard data.count >= 10 && data.isCRCValid else {
return nil
}
@ -22,8 +22,12 @@ struct BatteryStatusRxMessage: TransmitterRxMessage {
voltageA = Int(data.uint16(position: 2))
voltageB = Int(data.uint16(position: 4))
resist = Int(data.uint16(position: 6))
runtime = Int(data.uint16(position: 8))
temperature = Int(data.uint8(position: 10))
if data.count == 10 {// see https://github.com/NightscoutFoundation/xDrip/commit/b1fb0835a765a89ccc1bb8b216b0d6b2d21d66bb#diff-564e59f90a64b2928799ea4e30d81920
runtime = -1
} else {
runtime = Int(data[8])
}
temperature = Int(data.uint8(position: 9))
}
}