diff options
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r-- | src/main/java/org/traccar/model/Position.java | 1 | ||||
-rw-r--r-- | src/main/java/org/traccar/protocol/CastelProtocolDecoder.java | 31 |
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); |