aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
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
parentd395f5b42fd261265ca52b1674f17883b8c251c9 (diff)
downloadtrackermap-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.tar.gz
trackermap-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.tar.bz2
trackermap-server-570bd4f7e2a4183b315242d05ce1ab342c30a973.zip
Add support for G sensor
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/model/Position.java1
-rw-r--r--src/main/java/org/traccar/protocol/CastelProtocolDecoder.java31
2 files changed, 31 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java
index 6032dc588..90444cc9f 100644
--- a/src/main/java/org/traccar/model/Position.java
+++ b/src/main/java/org/traccar/model/Position.java
@@ -82,6 +82,7 @@ public class Position extends Message {
public static final String KEY_BLOCKED = "blocked";
public static final String KEY_DOOR = "door";
public static final String KEY_AXLE_WEIGHT = "axleWeight";
+ public static final String KEY_G_SENSOR = "gSensor";
public static final String KEY_DTCS = "dtcs";
public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
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);