aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-20 04:08:53 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-03-20 04:08:53 +1300
commit7fc40b50d77b5724473ffd91e8d1b00418c27cc2 (patch)
treea99ab9d1bdc4e61485c0382e31b6a856a6068bc0 /src
parent5706941ecce30e3a6d92cdf6e26a266573e63cd7 (diff)
downloadtrackermap-server-7fc40b50d77b5724473ffd91e8d1b00418c27cc2.tar.gz
trackermap-server-7fc40b50d77b5724473ffd91e8d1b00418c27cc2.tar.bz2
trackermap-server-7fc40b50d77b5724473ffd91e8d1b00418c27cc2.zip
Alternative TAIP acknowledgement
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index 099ae005d..24fe36220 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -18,6 +18,7 @@ package org.traccar.protocol;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.DateUtil;
import org.traccar.helper.Parser;
@@ -135,6 +136,10 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
attributes = sentence.substring(beginIndex, endIndex).split(";");
}
+ String uniqueId = null;
+ DeviceSession deviceSession = null;
+ String messageIndex = null;
+
if (attributes != null) {
for (String attribute : attributes) {
int index = attribute.indexOf('=');
@@ -144,13 +149,11 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
switch (key) {
case "id":
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
+ uniqueId = value;
+ deviceSession = getDeviceSession(channel, remoteAddress, value);
if (deviceSession != null) {
position.setDeviceId(deviceSession.getDeviceId());
}
- if (sendResponse && channel != null) {
- channel.write(value);
- }
break;
case "sv":
@@ -170,13 +173,26 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
break;
}
+ } else if (attribute.startsWith("#")) {
+ messageIndex = attribute;
}
}
}
- if (position.getDeviceId() != 0) {
+ if (deviceSession != null) {
+ if (sendResponse && channel != null) {
+ if (messageIndex != null) {
+ String response = ">ACK;" + messageIndex + ";ID=" + uniqueId + ";";
+ response += Checksum.nmea(response) + "<";
+ channel.write(response);
+ } else {
+ channel.write(uniqueId);
+ }
+ }
+
return position;
}
+
return null;
}