diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-10 14:10:00 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-10 14:10:00 +1300 |
commit | acfd6b43fc457cf98d5d1669f89438240bb871c2 (patch) | |
tree | e611038a8dba478d4726b4ff1d73b27048851415 /src/org/traccar/protocol | |
parent | 5634860cbe5c43007df354acba79d5051c1eb987 (diff) | |
download | trackermap-server-acfd6b43fc457cf98d5d1669f89438240bb871c2.tar.gz trackermap-server-acfd6b43fc457cf98d5d1669f89438240bb871c2.tar.bz2 trackermap-server-acfd6b43fc457cf98d5d1669f89438240bb871c2.zip |
Support extended RMC message format
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/T55ProtocolDecoder.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index c6b2a670e..71f493318 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -42,7 +42,13 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { .expression("([EW]),") .number("(d+.?d*)?,") // speed .number("(d+.?d*)?,") // course - .number("(dd)(dd)(dd)") // date + .number("(dd)(dd)(dd),") // date + .expression("[^*]+") + .text("*") + .expression("[^,]+") + .number(",(d+)") // satellites + .number(",(d+)") // imei + .number(",(d+)").optional(3) .any() .compile(); @@ -84,7 +90,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { private Position position = null; - private Position decodeGprmc(String sentence, Channel channel) { + private Position decodeGprmc(String sentence, SocketAddress remoteAddress, Channel channel) { if (channel != null) { channel.write("OK1\r\n"); @@ -114,6 +120,14 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); position.setTime(dateBuilder.getDate()); + if (parser.hasNext(3)) { + position.set(Event.KEY_SATELLITES, parser.next()); + if (!identify(parser.next(), channel, remoteAddress)) { + return null; + } + position.setDeviceId(getDeviceId()); + } + if (hasDeviceId()) { return position; } else { @@ -226,7 +240,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { } else if (Character.isDigit(sentence.charAt(0)) && sentence.length() == 15) { identify(sentence, channel, remoteAddress); } else if (sentence.startsWith("$GPRMC")) { - return decodeGprmc(sentence, channel); + return decodeGprmc(sentence, remoteAddress, channel); } else if (sentence.startsWith("$GPGGA") && hasDeviceId()) { return decodeGpgga(sentence); } else if (sentence.startsWith("$GPRMA") && hasDeviceId()) { |