aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-07-22 22:38:34 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-07-22 22:38:34 -0700
commitbd12d76efb0fe728f2f001afeb5c5cfaf979af43 (patch)
tree37051f22324d81606548989ec708edb07ee08386 /src/main/java/org/traccar/protocol
parent44241abf9dbafaec4faa982e673ebf1d447176fd (diff)
downloadtrackermap-server-bd12d76efb0fe728f2f001afeb5c5cfaf979af43.tar.gz
trackermap-server-bd12d76efb0fe728f2f001afeb5c5cfaf979af43.tar.bz2
trackermap-server-bd12d76efb0fe728f2f001afeb5c5cfaf979af43.zip
Fix battery decoding
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java9
1 files changed, 7 insertions, 2 deletions
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())));