aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java10
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java4
2 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index 4beee7696..d3c312f7e 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -41,6 +41,7 @@ import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.TimeZone;
+import java.util.stream.Collectors;
public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
@@ -919,14 +920,19 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.setTime(time);
break;
case 0x02:
- count = buf.readUnsignedByte();
+ List<String> codes = new LinkedList<>();
+ count = buf.readUnsignedShort();
for (int i = 0; i < count; i++) {
buf.readUnsignedInt(); // system id
int codeCount = buf.readUnsignedShort();
for (int j = 0; j < codeCount; j++) {
- buf.skipBytes(16); // code
+ buf.readUnsignedInt(); // dtc
+ buf.readUnsignedInt(); // status
+ codes.add(buf.readCharSequence(
+ buf.readUnsignedShort(), StandardCharsets.US_ASCII).toString().trim());
}
}
+ position.set(Position.KEY_DTCS, String.join(" ", codes));
getLastLocation(position, time);
decodeCoordinates(position, buf);
position.setTime(time);
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index 2f317d049..5fd9ed894 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -15,6 +15,10 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
"7e010200204f07788ef67601824f4459344f544d314d4459774d4441314d444977626d5633553235536457786cba7e"));
verifyAttribute(decoder, binary(
+ "7e090000344f07788ef87d0138f02305151230460102020001ffffffff000100001457000000020006503134353700000c000a029dc63004b99a98230515132726787e"),
+ Position.KEY_DTCS, "P1457");
+
+ verifyAttribute(decoder, binary(
"7e0200006476806111898300710000000000100046005d3156065f7128000000000000230511165956660b01fe000001031a5d1a8101670831333231343332326902018b6a01166b01006c0f323034303830393230373533363735711438393434343738383030303030323131303030464b7e"),
Position.KEY_BATTERY, 3.95);