From a7a5e0ad20d707e7f3527503ed124c6986118e87 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 18 Nov 2023 06:10:11 -0800 Subject: Modify TAIP ACK order --- src/main/java/org/traccar/protocol/TaipProtocolDecoder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java index 72090df8b..e953756b5 100644 --- a/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TaipProtocolDecoder.java @@ -264,6 +264,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { String uniqueId = null; DeviceSession deviceSession = null; String messageIndex = null; + boolean indexFirst = true; if (attributes != null) { for (String attribute : attributes) { @@ -278,6 +279,9 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { if (deviceSession != null) { position.setDeviceId(deviceSession.getDeviceId()); } + if (messageIndex == null) { + indexFirst = false; + } break; case "io": position.set(Position.KEY_IGNITION, BitUtil.check(value.charAt(0) - '0', 0)); @@ -317,7 +321,11 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { if (messageIndex.startsWith("#IP")) { response = ">SAK;ID=" + uniqueId + ";" + messageIndex + "<"; } else { - response = ">ACK;" + messageIndex + ";ID=" + uniqueId + ";*"; + if (indexFirst) { + response = ">ACK;" + messageIndex + ";ID=" + uniqueId + ";*"; + } else { + response = ">ACK;ID=" + uniqueId + ";" + messageIndex + ";*"; + } response += String.format("%02X", Checksum.xor(response)) + "<"; } channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); -- cgit v1.2.3