aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-05-20 07:17:42 +0300
committerAnton Tananaev <anton.tananaev@gmail.com>2019-05-20 07:17:42 +0300
commit570bd4f7e2a4183b315242d05ce1ab342c30a973 (patch)
tree91f78b350500ef4bc12bbb356450527fd475ee97 /src/main/java/org/traccar/protocol
parentd395f5b42fd261265ca52b1674f17883b8c251c9 (diff)
downloadtraccar-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.tar.gz
traccar-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.tar.bz2
traccar-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.zip
Add support for G sensor
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/CastelProtocolDecoder.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java b/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
index 1f67b6a77..03e4b25fd 100644
--- a/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/CastelProtocolDecoder.java
@@ -292,6 +292,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
int version, ByteBuf id, short type, DeviceSession deviceSession) {
Position position;
+ int count;
switch (type) {
@@ -330,7 +331,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
long status = buf.readUnsignedIntLE();
buf.skipBytes(8);
- int count = buf.readUnsignedByte();
+ count = buf.readUnsignedByte();
List<Position> positions = new LinkedList<>();
@@ -380,6 +381,34 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
return position;
+ case MSG_SC_G_SENSOR:
+ position = createPosition(deviceSession);
+
+ decodeStat(position, buf);
+
+ buf.readUnsignedShortLE(); // sample rate
+
+ count = buf.readUnsignedByte();
+
+ StringBuilder data = new StringBuilder("[");
+ for (int i = 0; i < count; i++) {
+ if (i > 0) {
+ data.append(",");
+ }
+ data.append("[");
+ data.append(buf.readShortLE() * 0.015625);
+ data.append(",");
+ data.append(buf.readShortLE() * 0.015625);
+ data.append(",");
+ data.append(buf.readShortLE() * 0.015625);
+ data.append("]");
+ }
+ data.append("]");
+
+ position.set(Position.KEY_G_SENSOR, data.toString());
+
+ return position;
+
case MSG_SC_DTCS_PASSENGER:
position = createPosition(deviceSession);