From bd12d76efb0fe728f2f001afeb5c5cfaf979af43 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 22 Jul 2020 22:38:34 -0700 Subject: Fix battery decoding --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/protocol') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 335dcd796..841e2235d 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -335,8 +335,13 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RSSI, buf.readUnsignedByte()); position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000L); - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); - position.set(Position.KEY_CHARGE, buf.readUnsignedByte() == 0xAA); + + int battery = buf.readUnsignedByte(); + if (battery <= 100) { + position.set(Position.KEY_BATTERY_LEVEL, battery); + } else if (battery == 0xAA) { + position.set(Position.KEY_CHARGE, true); + } position.setNetwork(new Network(CellTower.fromCidLac(buf.readUnsignedInt(), buf.readUnsignedShort()))); -- cgit v1.2.3