diff options
Diffstat (limited to 'src/main/java/org')
-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) { |