aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-10-07 11:36:12 +0500
committerAbyss777 <abyss@fox5.ru>2016-10-07 11:36:12 +0500
commit7ee3482b31288d29d7a46fbdf4ffba6732159a89 (patch)
treea50ca9d1c30ed6f938c79cabfc0ff02672b42aa2 /src/org/traccar
parent4b816255f5e55cddd8ea022b940f33bd204aeb60 (diff)
downloadtrackermap-server-7ee3482b31288d29d7a46fbdf4ffba6732159a89.tar.gz
trackermap-server-7ee3482b31288d29d7a46fbdf4ffba6732159a89.tar.bz2
trackermap-server-7ee3482b31288d29d7a46fbdf4ffba6732159a89.zip
- Handle GTVER packets
- Added few alarms
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/model/Position.java2
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java64
2 files changed, 64 insertions, 2 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 3a7070083..abe8dd813 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -93,6 +93,8 @@ public class Position extends Message {
public static final String ALARM_BREAKING = "hardBreaking";
public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving";
public static final String ALARM_POWER_CUT = "powerCut";
+ public static final String ALARM_JAMMING = "jamming";
+ public static final String ALARM_TEMPERATURE = "temperature";
private String protocol;
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 7187aa7cc..973907235 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -88,6 +88,20 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text("$").optional()
.compile();
+ private static final Pattern PATTERN_VER = new PatternBuilder()
+ .text("+").expression("(?:RESP|BUFF):GTVER,")
+ .number("[0-9A-Z]{2}xxxx,") // protocol version
+ .number("(d{15}),") // imei
+ .expression("[^,]*,") // device name
+ .expression("([^,]*),") // device type
+ .number("(xxxx),") // firmware version
+ .number("(xxxx),") // hardware version
+ .number("(dddd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
+ .number("(xxxx)") // counter
+ .text("$").optional()
+ .compile();
+
private static final Pattern PATTERN_LOCATION = new PatternBuilder()
.number("(?:d{1,2})?,") // gps accuracy
.number("(d{1,3}.d)?,") // speed
@@ -331,6 +345,34 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
+ private Object decodeVer(Channel channel, SocketAddress remoteAddress, String sentence) {
+ Parser parser = new Parser(PATTERN_VER, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
+ if (deviceSession == null) {
+ return null;
+ }
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ position.set("deviceType", parser.next());
+ position.set("firmwareVersion", parser.nextInt(16));
+ position.set("hardwareVersion", parser.nextInt(16));
+
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+
+ getLastLocation(position, dateBuilder.getDate());
+
+ return position;
+ }
+
private void decodeLocation(Position position, Parser parser) {
position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
position.setCourse(parser.nextDouble());
@@ -587,7 +629,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBasic(Channel channel, SocketAddress remoteAddress, String sentence) {
+ private Object decodeBasic(Channel channel, SocketAddress remoteAddress, String sentence, String type) {
Parser parser = new Parser(PATTERN_BASIC, sentence);
if (!parser.matches()) {
return null;
@@ -624,6 +666,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
}
+ switch (type) {
+ case "BPL":
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ case "TEM":
+ position.set(Position.KEY_ALARM, Position.ALARM_TEMPERATURE);
+ break;
+ case "JDR":
+ case "JDS":
+ position.set(Position.KEY_ALARM, Position.ALARM_JAMMING);
+ break;
+ default:
+ break;
+ }
+
return position;
}
@@ -660,13 +717,16 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
case "IDA":
result = decodeIda(channel, remoteAddress, sentence);
break;
+ case "VER":
+ result = decodeVer(channel, remoteAddress, sentence);
+ break;
default:
result = decodeOther(channel, remoteAddress, sentence, type);
break;
}
if (result == null) {
- result = decodeBasic(channel, remoteAddress, sentence);
+ result = decodeBasic(channel, remoteAddress, sentence, type);
}
if (result != null) {