From b56878dde35a8cc9275707a9c486a3cb095a09f5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 10 Aug 2020 20:25:31 -0700 Subject: Fix battery level decoding --- src/main/java/org/traccar/protocol/T800xProtocolDecoder.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java index 3331ebb71..5822d6b8f 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolDecoder.java @@ -230,10 +230,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); int battery = BcdUtil.readInteger(buf, 2); - if (battery == 0) { - battery = 100; - } - position.set(Position.KEY_BATTERY, battery); + position.set(Position.KEY_BATTERY_LEVEL, battery > 0 ? battery : 100); } @@ -284,7 +281,8 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_G_SENSOR, "[" + accelerationX + "," + accelerationY + "," + accelerationZ + "]"); - position.set(Position.KEY_BATTERY_LEVEL, BcdUtil.readInteger(buf, 2)); + int battery = BcdUtil.readInteger(buf, 2); + position.set(Position.KEY_BATTERY_LEVEL, battery > 0 ? battery : 100); position.set(Position.KEY_DEVICE_TEMP, (int) buf.readByte()); position.set("lightSensor", BcdUtil.readInteger(buf, 2) * 0.1); position.set(Position.KEY_BATTERY, BcdUtil.readInteger(buf, 2) * 0.1); -- cgit v1.2.3