aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-03-22 19:21:07 -0700
committerAnton Tananaev <anton@traccar.org>2023-03-22 19:21:07 -0700
commitee3cbd4aba2e7df2ac2da4292caa87a63b171a87 (patch)
tree1708728a4ab7d0eb9b1a4fc7eab3f442503ada92 /src
parentf8fb3f67bc0bc44f9da89c3dabbec7406751e3c6 (diff)
downloadtrackermap-server-ee3cbd4aba2e7df2ac2da4292caa87a63b171a87.tar.gz
trackermap-server-ee3cbd4aba2e7df2ac2da4292caa87a63b171a87.tar.bz2
trackermap-server-ee3cbd4aba2e7df2ac2da4292caa87a63b171a87.zip
Decode JT705A tilt
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.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"));