aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-29 16:40:01 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-29 16:40:01 +1300
commit35b82397627fa48505861ec69da34fa9164a60b5 (patch)
treea931e017c32e6447f9110a235af33a98928cff83 /src/org/traccar
parent9a7e9e1b5822351c2c7aec8d6f1fde5b637afaaf (diff)
downloadtraccar-server-35b82397627fa48505861ec69da34fa9164a60b5.tar.gz
traccar-server-35b82397627fa48505861ec69da34fa9164a60b5.tar.bz2
traccar-server-35b82397627fa48505861ec69da34fa9164a60b5.zip
Support GL200 info messages
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java101
1 files changed, 80 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 2863fbaf8..a0d8bd1b2 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -41,6 +41,33 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.text("$").optional()
.compile();
+ private static final Pattern PATTERN_INF = new PatternBuilder()
+ .text("+RESP:GTINF,")
+ .number("[0-9A-Z]{2}xxxx,") // protocol version
+ .number("(d{15}),") // imei
+ .expression("[0-9A-Z]{17},") // vin
+ .expression("[^,]{0,20},") // device name
+ .number("(xx),") // state
+ .expression("[0-9F]{20},") // iccid
+ .number("d{1,2},")
+ .number("d{1,2},")
+ .expression("[01],")
+ .number("(d{1,5}),") // power
+ .text(",")
+ .number("(d+.d+),") // battery
+ .expression("([01]),") // charging
+ .expression("[01],")
+ .text(",,")
+ .number("d{14},") // last fix time
+ .text(",,,,,")
+ .number("[-+]dddd,") // timezone
+ .expression("[01],") // daylight saving
+ .number("(dddd)(dd)(dd)") // date
+ .number("(dd)(dd)(dd),") // time
+ .number("(xxxx)") // counter
+ .text("$").optional()
+ .compile();
+
private static final Pattern PATTERN = new PatternBuilder()
.groupBegin()
.text("+").expression("(?:RESP|BUFF)").text(":")
@@ -78,16 +105,17 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.or().any()
.groupEnd().text(",")
- .number("(d*),") // gps accuracy
- .number("(d+.d)?,") // speed
- .number("(d+)?,") // course
- .number("(-?d+.d)?,") // altitude
- .number("(-?d+.d+),") // longitude
- .number("(-?d+.d+),") // latitude
+ .number("(d{1,2})?,") // gps accuracy
+ .number("(d{1,3}.d)?,") // speed
+ .number("(d{1,3})?,") // course
+ .number("(-?d{1,5}.d)?,") // altitude
+ .number("(-?d{1,3}.d{6})?,") // longitude
+ .number("(-?d{1,2}.d{6})?,") // latitude
.number("(dddd)(dd)(dd)") // date
- .number("(dd)(dd)(dd),") // time
- .number("(dddd)?,") // mcc
- .number("(dddd)?,") // mnc
+ .number("(dd)(dd)(dd)").optional(2) // time
+ .text(",")
+ .number("(0ddd)?,") // mcc
+ .number("(0ddd)?,") // mnc
.number("(xxxx|x{8})?,") // loc
.number("(xxxx)?,") // cell
.groupBegin()
@@ -95,7 +123,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
.number("(d{1,3})?,") // battery
.groupEnd("?")
.any().text(",")
- .number("(xxxx)\\$?")
+ .number("(xxxx)")
.text("$").optional()
.compile();
@@ -111,6 +139,33 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
+ parser = new Parser(PATTERN_INF, (String) msg);
+ if (parser.matches()) {
+
+ Position position = new Position();
+ position.setProtocol(getProtocolName());
+
+ if (!identify(parser.next(), channel, remoteAddress)) {
+ return null;
+ }
+ position.setDeviceId(getDeviceId());
+
+ position.set(Event.KEY_STATUS, parser.next());
+ position.set(Event.KEY_POWER, parser.next());
+ position.set(Event.KEY_BATTERY, parser.next());
+ position.set(Event.KEY_CHARGE, parser.next());
+
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+
+ getLastLocation(position, dateBuilder.getDate());
+
+ position.set(Event.KEY_INDEX, parser.next());
+
+ return position;
+ }
+
parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
return null;
@@ -137,17 +192,21 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_FUEL, parser.next());
position.set(Event.KEY_OBD_ODOMETER, parser.next());
- position.setValid(parser.nextInt() < 20);
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
- position.setCourse(parser.nextDouble());
- position.setAltitude(parser.nextDouble());
- position.setLongitude(parser.nextDouble());
- position.setLatitude(parser.nextDouble());
-
- DateBuilder dateBuilder = new DateBuilder()
- .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
- .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
- position.setTime(dateBuilder.getDate());
+ if (parser.hasNext(12)) {
+ position.setValid(parser.nextInt() < 20);
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble()));
+ position.setCourse(parser.nextDouble());
+ position.setAltitude(parser.nextDouble());
+ position.setLongitude(parser.nextDouble());
+ position.setLatitude(parser.nextDouble());
+
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt())
+ .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
+ position.setTime(dateBuilder.getDate());
+ } else {
+ getLastLocation(position, null);
+ }
position.set(Event.KEY_MCC, parser.next());
position.set(Event.KEY_MNC, parser.next());