aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-11-03 22:53:16 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-11-03 22:53:16 -0700
commitb563ec10b48742f34fe9f9738b0b4ce5967d0fe6 (patch)
tree25efbaa68f9396a1b75bf691cfc90602cc03c968 /src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
parent4a00ea7be7c0a7102d5a19c8fcc2cdcec58319af (diff)
downloadtrackermap-server-b563ec10b48742f34fe9f9738b0b4ce5967d0fe6.tar.gz
trackermap-server-b563ec10b48742f34fe9f9738b0b4ce5967d0fe6.tar.bz2
trackermap-server-b563ec10b48742f34fe9f9738b0b4ce5967d0fe6.zip
Decode acceleration data
Diffstat (limited to 'src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
index 05411addf..3c01c0468 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -53,6 +53,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TERMINAL_CONTROL = 0x8105;
public static final int MSG_TERMINAL_AUTH = 0x0102;
public static final int MSG_LOCATION_REPORT = 0x0200;
+ public static final int MSG_ACCELERATION = 0x2070;
public static final int MSG_LOCATION_REPORT_2 = 0x5501;
public static final int MSG_LOCATION_REPORT_BLIND = 0x5502;
public static final int MSG_LOCATION_BATCH = 0x0704;
@@ -136,6 +137,11 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ private int readSignedWord(ByteBuf buf) {
+ int value = buf.readUnsignedShort();
+ return BitUtil.check(value, 15) ? -BitUtil.to(value, 15) : BitUtil.to(value, 15);
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -216,6 +222,33 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, false, response), remoteAddress));
}
+ } else if (type == MSG_ACCELERATION) {
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ StringBuilder data = new StringBuilder("[");
+ while (buf.readableBytes() > 2) {
+ buf.skipBytes(6); // time
+ if (data.length() > 1) {
+ data.append(",");
+ }
+ data.append("[");
+ data.append(readSignedWord(buf));
+ data.append(",");
+ data.append(readSignedWord(buf));
+ data.append(",");
+ data.append(readSignedWord(buf));
+ data.append("]");
+ }
+ data.append("]");
+
+ position.set(Position.KEY_G_SENSOR, data.toString());
+
+ return position;
+
}
return null;