From 7fc40b50d77b5724473ffd91e8d1b00418c27cc2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 20 Mar 2017 04:08:53 +1300 Subject: Alternative TAIP acknowledgement --- src/org/traccar/protocol/TaipProtocolDecoder.java | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/org/traccar') 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; } -- cgit v1.2.3