diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-10-15 11:02:00 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-10-15 11:02:00 +1300 |
commit | adb0e8c004db89c4248b91613a126cd81efb4587 (patch) | |
tree | f44870e751531279836e4465f8cf2903f4e65a94 /src/org | |
parent | 48f57acd31fc5b0ae3b9de85e72c58c7186f5475 (diff) | |
download | traccar-server-adb0e8c004db89c4248b91613a126cd81efb4587.tar.gz traccar-server-adb0e8c004db89c4248b91613a126cd81efb4587.tar.bz2 traccar-server-adb0e8c004db89c4248b91613a126cd81efb4587.zip |
Handle alternative ITS message types
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/ItsProtocolDecoder.java | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/org/traccar/protocol/ItsProtocolDecoder.java b/src/org/traccar/protocol/ItsProtocolDecoder.java index 53d796b03..79eca21ce 100644 --- a/src/org/traccar/protocol/ItsProtocolDecoder.java +++ b/src/org/traccar/protocol/ItsProtocolDecoder.java @@ -34,18 +34,30 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("$,") - .expression("[^,]+,") // header + .expression("[^,]+,") // event + .groupBegin() + .expression("[^,]+,") // vendor + .number("d+.d+.d+,") // firmware version + .groupEnd("?") .expression("[^,]+,") // type + .groupBegin() + .number("d+,") + .expression("[LH],") // history + .groupEnd("?") .number("(d{15}),") // imei + .groupBegin() .expression("(?:NM|SP),") // status + .or() + .expression("[^,]+,") // vehicle registration + .number("([01]),") // valid + .groupEnd() .number("(dd),(dd),(dddd),") // date (ddmmyyyy) .number("(dd),(dd),(dd),") // time (hhmmss) - .expression("([AV]),") // valid + .expression("([AV]),").optional() // valid .number("(d+.d+),([NS]),") // latitude .number("(d+.d+),([EW]),") // longitude - .number("(-?d+.d+),") // altitude + .number("(-?d+.d+),").optional() // altitude .number("(d+.d+),") // speed - .number("(d+.d+),") // distance .any() .compile(); @@ -66,15 +78,18 @@ public class ItsProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + if (parser.hasNext()) { + position.setValid(parser.nextInt() == 1); + } position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); - position.setValid(parser.next().equals("A")); + if (parser.hasNext()) { + position.setValid(parser.next().equals("A")); + } position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); - position.setAltitude(parser.nextDouble()); + position.setAltitude(parser.nextDouble(0)); position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); - position.set(Position.KEY_ODOMETER, parser.nextDouble()); - return position; } |