diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-20 22:29:15 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-20 22:29:15 -0800 |
commit | 81d4920ba7e45d762f7e276195b9b085e88249a4 (patch) | |
tree | fd483b8d0625604107f8ce8afcb1cfe7909389bd | |
parent | 13a59da88ee76b8d1f927284b98ef14949584252 (diff) | |
download | trackermap-server-81d4920ba7e45d762f7e276195b9b085e88249a4.tar.gz trackermap-server-81d4920ba7e45d762f7e276195b9b085e88249a4.tar.bz2 trackermap-server-81d4920ba7e45d762f7e276195b9b085e88249a4.zip |
Decode additional data
-rw-r--r-- | src/org/traccar/protocol/HuabaoProtocolDecoder.java | 21 | ||||
-rw-r--r-- | test/org/traccar/protocol/HuabaoProtocolDecoderTest.java | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java index 2eb75a710..f5e73c1f9 100644 --- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -193,7 +193,24 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { .setSecond(BcdUtil.readInteger(buf, 2)); position.setTime(dateBuilder.getDate()); - // additional information + while (buf.readableBytes() > 2) { + int subtype = buf.readUnsignedByte(); + int length = buf.readUnsignedByte(); + switch (subtype) { + case 0x01: + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 100); + break; + case 0x30: + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + break; + case 0x31: + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); + break; + default: + buf.skipBytes(length); + break; + } + } return position; } diff --git a/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java index 8f8b5fe24..d4ae3b50c 100644 --- a/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -14,6 +14,9 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { "7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E")); verifyPosition(decoder, binary( + "7e020000400303000002280042000000000000000301618ab406c31ec800000000000518092116145701040000047830011031010aeb16000c00b28986011780108622216500060089ffffffffc37e")); + + verifyPosition(decoder, binary( "7E0200002A013833501744001900000000000000C201597FA806CC01580080000000081508180721210104000002F502020000030200009F7E")); verifyPositions(decoder, binary( |