aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java14
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index b9b156f93..6d57c3339 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -249,7 +249,21 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
.setSecond(BcdUtil.readInteger(buf, 2));
position.setTime(dateBuilder.getDate());
+ if (buf.readableBytes() == 20) {
+
+ buf.skipBytes(4); // remaining battery and mileage
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.1);
+ buf.readUnsignedInt(); // area id
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
+ buf.skipBytes(3); // reserved
+
+ return position;
+
+ }
+
while (buf.readableBytes() > 2) {
+
int subtype = buf.readUnsignedByte();
int length = buf.readUnsignedByte();
int endIndex = buf.readerIndex() + length;
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index f44accc57..8e9e8c1d4 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E"));
+ verifyPosition(decoder, binary(
+ "7e0200002e202000129707001c0000000000001c0601a2f0a8091f0bf00000000000ed201103031733000000000000000000780000000018000000267e"));
+
verifyAttribute(decoder, binary(
"7e070400db07904116875014480003010046000000000000000b020057d40072fb9c0064017200f220090215230301040000092930011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1d460046000000000000000b0200570c0072fdb2005f013600ee20090215230801040000092a30011f31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e800046000000000000000b020056ac0072fe9b005a00d200ec20090215231301040000092a30011b31010ceb1c000c00b28921200272401241734f00060089ffffffef000400ce1e35d77e"),
Position.KEY_POWER, 74.94);