aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/T55ProtocolDecoder.java
diff options
context:
space:
mode:
authorHans van den Elsen <hans.elsen@esds.nl>2016-03-11 22:16:25 +0100
committerHans van den Elsen <hans.elsen@esds.nl>2016-03-11 22:16:25 +0100
commit4606737cc07b736f9c8f98ae680b928c94c082c8 (patch)
treebdd29b24a16403b1e8a3d7cd4325391063b34b8a /src/org/traccar/protocol/T55ProtocolDecoder.java
parent3ced99384b1967f5cde9abdf30c1c0184a5ae3f6 (diff)
parentab5d21e16ac44957e04da0f06daf148af95e96be (diff)
downloadtrackermap-server-4606737cc07b736f9c8f98ae680b928c94c082c8.tar.gz
trackermap-server-4606737cc07b736f9c8f98ae680b928c94c082c8.tar.bz2
trackermap-server-4606737cc07b736f9c8f98ae680b928c94c082c8.zip
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/protocol/T55ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 9c47d1ab0..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 {
@@ -217,7 +231,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
} else if (sentence.startsWith("IMEI")) {
identify(sentence.substring(5, sentence.length()), channel, remoteAddress);
} else if (sentence.startsWith("$GPFID")) {
- if (identify(sentence.substring(6, sentence.length()), channel, remoteAddress) && position != null) {
+ if (identify(sentence.substring(7, sentence.length()), channel, remoteAddress) && position != null) {
Position position = this.position;
position.setDeviceId(getDeviceId());
this.position = null;
@@ -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()) {