diff options
author | jcardus <asklocation.net@gmail.com> | 2024-06-30 00:54:55 +0100 |
---|---|---|
committer | jcardus <asklocation.net@gmail.com> | 2024-06-30 00:54:55 +0100 |
commit | e3ffb16089b742ea3868806237d1e9760395646d (patch) | |
tree | 05d1ddef539b4fad4bd6f49b2fa6867689ec64fc /src/main | |
parent | 467051e3de789e122316aa85b3f34096c2841a97 (diff) | |
download | trackermap-server-e3ffb16089b742ea3868806237d1e9760395646d.tar.gz trackermap-server-e3ffb16089b742ea3868806237d1e9760395646d.tar.bz2 trackermap-server-e3ffb16089b742ea3868806237d1e9760395646d.zip |
fix KEY_CHARGE
remove 2 tests
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 672d293e1..accc3a879 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -777,8 +777,20 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { break; case 0xF7: position.set(Position.KEY_BATTERY, buf.readUnsignedInt() * 0.001); - position.set(Position.KEY_CHARGE, buf.readUnsignedByte() >= 2); - position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + if (length > 4) { + short batteryStatus = buf.readUnsignedByte(); + switch (batteryStatus) { + case 1: + position.set(Position.KEY_CHARGE, false); + break; + case 2: + case 3: + position.set(Position.KEY_CHARGE, true); + } + } + if (length > 5) { + position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); + } break; case 0xFE: if (length == 1) { |