aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-10-08 01:28:27 +1300
committerGitHub <noreply@github.com>2016-10-08 01:28:27 +1300
commit8e38a798ea6241e823f654d1467c1a143643c16d (patch)
treeeac48b39897fe5dceae7e44d710c3682359f9c8b /src/org/traccar/protocol
parent5451efd2f5d343cb6c7e6964055305103b4fbdd2 (diff)
parent7ee3482b31288d29d7a46fbdf4ffba6732159a89 (diff)
downloadtrackermap-server-8e38a798ea6241e823f654d1467c1a143643c16d.tar.gz
trackermap-server-8e38a798ea6241e823f654d1467c1a143643c16d.tar.bz2
trackermap-server-8e38a798ea6241e823f654d1467c1a143643c16d.zip
Merge pull request #2417 from Abyss777/gl200
GL200: GTVER packets and a few small improvements
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 2d28ea199..973907235 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -50,7 +50,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN_INF = new PatternBuilder()
- .text("+RESP:GTINF,")
+ .text("+").expression("(?:RESP|BUFF):GTINF,")
.number("[0-9A-Z]{2}xxxx,") // protocol version
.number("(d{15}),") // imei
.expression("(?:[0-9A-Z]{17},)?") // vin
@@ -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) {