diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-04-16 09:53:29 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-04-16 09:53:29 +1200 |
commit | 7c3493a088f94d8d37d53cab66756947be230276 (patch) | |
tree | 492e54a1f00ce73d783ca1fbac2e5cdddd186d90 /src | |
parent | 2f0687aee12999697596c9b028e6d2736d8df6b7 (diff) | |
download | trackermap-server-7c3493a088f94d8d37d53cab66756947be230276.tar.gz trackermap-server-7c3493a088f94d8d37d53cab66756947be230276.tar.bz2 trackermap-server-7c3493a088f94d8d37d53cab66756947be230276.zip |
Improve Appello protocol decoder
Diffstat (limited to 'src')
-rwxr-xr-x | src/org/traccar/protocol/AppelloProtocolDecoder.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/AppelloProtocolDecoder.java b/src/org/traccar/protocol/AppelloProtocolDecoder.java index f04623759..d422a5aa1 100755 --- a/src/org/traccar/protocol/AppelloProtocolDecoder.java +++ b/src/org/traccar/protocol/AppelloProtocolDecoder.java @@ -35,14 +35,18 @@ public class AppelloProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN = new PatternBuilder() .text("FOLLOWIT,") // brand .number("(d+),") // imei + .groupBegin() .number("(dd)(dd)(dd)") // date .number("(dd)(dd)(dd).?d*,") // time + .or() + .text("UTCTIME,") + .groupEnd() .number("(-?d+.d+),") // latitude .number("(-?d+.d+),") // longitude .number("(d+),") // speed .number("(d+),") // course .number("(d+),") // satellites - .number("(d+),") // altitude + .number("(-?d+),") // altitude .expression("([FL]),") // gps state .any() .compile(); @@ -65,10 +69,14 @@ public class AppelloProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(getDeviceId()); - 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(6)) { + 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.setLatitude(parser.nextDouble()); position.setLongitude(parser.nextDouble()); |