aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/T55ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-04 11:16:32 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-04 11:16:32 +1300
commit88e4230624ee5c2de9806751ed433c57a56f4856 (patch)
treed1082a3e736a2f2427058b9cf3c123c3a322543f /src/org/traccar/protocol/T55ProtocolDecoder.java
parent93fd4f3618b2a9f5b83cf8ba5b8312bf411969db (diff)
downloadtrackermap-server-88e4230624ee5c2de9806751ed433c57a56f4856.tar.gz
trackermap-server-88e4230624ee5c2de9806751ed433c57a56f4856.tar.bz2
trackermap-server-88e4230624ee5c2de9806751ed433c57a56f4856.zip
Modify T55 to support Maxon devices (fix #40)
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);