diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/protocol/TaipProtocolDecoder.java | 26 |
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; } |