aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/T55ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/T55ProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 42db4c753..d8b3eefe8 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -82,6 +82,8 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private Position position = null;
+
private Position decodeGprmc(String sentence, Channel channel) {
if (channel != null) {
@@ -95,7 +97,10 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setProtocol(getProtocolName());
- position.setDeviceId(getDeviceId());
+
+ if (hasDeviceId()) {
+ position.setDeviceId(getDeviceId());
+ }
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
@@ -109,7 +114,12 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- return position;
+ if (hasDeviceId()) {
+ return position;
+ } else {
+ this.position = position; // save position
+ return null;
+ }
}
private Position decodeGpgga(String sentence) {
@@ -207,10 +217,15 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
} else if (sentence.startsWith("IMEI")) {
identify(sentence.substring(5, sentence.length()), channel);
} else if (sentence.startsWith("$GPFID")) {
- identify(sentence.substring(6, sentence.length()), channel);
+ if (identify(sentence.substring(6, sentence.length()), channel) && position != null) {
+ Position position = this.position;
+ position.setDeviceId(getDeviceId());
+ this.position = null;
+ return position;
+ }
} else if (Character.isDigit(sentence.charAt(0)) && sentence.length() == 15) {
identify(sentence, channel);
- } else if (sentence.startsWith("$GPRMC") && hasDeviceId()) {
+ } else if (sentence.startsWith("$GPRMC")) {
return decodeGprmc(sentence, channel);
} else if (sentence.startsWith("$GPGGA") && hasDeviceId()) {
return decodeGpgga(sentence);