aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-01-07 09:49:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-01-07 09:49:43 +1300
commitcf78794053bf2e6890e279c49471a936698bde1f (patch)
treed9513556e1aa76e330143092e2e50912dbd4a42f /src/org/traccar/protocol
parent32d0c2e760fdc9f9b7b0b2c4160987c463d27f99 (diff)
downloadtrackermap-server-cf78794053bf2e6890e279c49471a936698bde1f.tar.gz
trackermap-server-cf78794053bf2e6890e279c49471a936698bde1f.tar.bz2
trackermap-server-cf78794053bf2e6890e279c49471a936698bde1f.zip
Support GT30 alarm messages
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gt30ProtocolDecoder.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/Gt30ProtocolDecoder.java b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
index 19d964687..6c3f8c0a4 100644
--- a/src/org/traccar/protocol/Gt30ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
@@ -37,6 +37,7 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
.number("x{4}") // length
.expression("(.{14})") // device id
.number("x{4}") // type
+ .expression("(.)?") // alarm
.number("(dd)(dd)(dd).(d+),") // time
.expression("([AV]),") // validity
.number("(d+)(dd.d+),") // latitude
@@ -52,6 +53,23 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
.number("x{4}") // checksum
.compile();
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ return Position.ALARM_SOS;
+ case 0x10:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x11:
+ return Position.ALARM_OVERSPEED;
+ case 0x12:
+ return Position.ALARM_GEOFENCE;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -70,6 +88,10 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next().charAt(0)));
+ }
+
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());