aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java14
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java2
2 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 d3336b60c..22c39c2da 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -761,7 +761,19 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(buf.readShort());
break;
case 0x0C:
- position.set("gyro", ByteBufUtil.hexDump(buf.readSlice(6)));
+ int x = buf.readUnsignedShort();
+ if (x > 0x8000) {
+ x -= 0x10000;
+ }
+ int y = buf.readUnsignedShort();
+ if (y > 0x8000) {
+ y -= 0x10000;
+ }
+ int z = buf.readUnsignedShort();
+ if (z > 0x8000) {
+ z -= 0x10000;
+ }
+ position.set("tilt", String.format("[%d,%d,%d]", x, y, z));
break;
default:
buf.skipBytes(length);
diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index 9590f7732..1737593e4 100644
--- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -16,7 +16,7 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest {
verifyAttribute(decoder, binary(
"7e55019c3b8571110003399a07032310302029538631031015370500001a0c000000265700440001233703080000001001020202000a0a04028f000af401040c06ff98ffa8007e707e"),
- "gyro", "ff98ffa8007e");
+ "tilt", "[-104,-88,126]");
verifyPosition(decoder, binary(
"7e0900001f4f07788ef87d000cf0230223150215010203013800000c000b029dc58c04b99b60230223171822507e"));