aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java13
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java4
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index c280ee9b2..9f54c8486 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -493,7 +493,18 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte());
break;
case 0xD5:
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
+ if (length == 2) {
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
+ } else {
+ int count = buf.readUnsignedByte();
+ for (int i = 1; i <= count; i++) {
+ position.set("lock" + i + "Id", ByteBufUtil.hexDump(buf.readSlice(5)));
+ position.set("lock" + i + "Card", ByteBufUtil.hexDump(buf.readSlice(5)));
+ position.set("lock" + i + "Battery", buf.readUnsignedByte());
+ int status = buf.readUnsignedShort();
+ position.set("lock" + i + "Locked", !BitUtil.check(status, 5));
+ }
+ }
break;
case 0xDA:
buf.readUnsignedShort(); // string cut count
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index d61dae315..c45effbc5 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -14,6 +14,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, buffer(
"(794104004140,1,001,BASE,2,TIME)"));
+ verifyAttribute(decoder, binary(
+ "7E02000053200002604323004800000000000C00000158B91406CB7007006B00000000220512101138010400000F2803020000250400000000300114310100E30100D50E0100026043232795980277530030E50400000000E7020FC8E8020E83AB7E"),
+ "lock1Locked", false);
+
verifyPosition(decoder, binary(
"7E0900005A4E5DE66FBA2200C4F02204280610090002010D052B0150052C0400129009052D016B052E014F05300231BA053502000005360203B8053802000005390200AD053D0201EA05440150054604009899D90545040000001E000C00030160A85C06D1C1389C7E"));