From a97c12829e99b63f1951bffc658c37ec180e5379 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 10 May 2018 19:06:13 -0700 Subject: Fix EGTS auth response --- src/org/traccar/protocol/EgtsProtocolDecoder.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/protocol/EgtsProtocolDecoder.java') diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java index 420701e6c..6ac7af440 100644 --- a/src/org/traccar/protocol/EgtsProtocolDecoder.java +++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java @@ -81,9 +81,13 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { data.writeBytes(content); ChannelBuffer record = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); + if (packetType == PT_RESPONSE) { + record.writeShort(index); + record.writeByte(0); // success + } record.writeShort(data.readableBytes()); - record.writeShort(index); - record.writeByte(1 << 6); // flags + record.writeShort(0); + record.writeByte(0); // flags (possibly 1 << 6) record.writeByte(serviceType); record.writeByte(serviceType); record.writeBytes(data); @@ -113,6 +117,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; + int index = buf.getUnsignedShort(buf.readerIndex() + 5 + 2); buf.skipBytes(buf.getUnsignedByte(buf.readerIndex() + 3)); List positions = new LinkedList<>(); @@ -120,7 +125,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { while (buf.readableBytes() > 2) { int length = buf.readUnsignedShort(); - int index = buf.readUnsignedShort(); + int recordIndex = buf.readUnsignedShort(); int recordFlags = buf.readUnsignedByte(); if (BitUtil.check(recordFlags, 0)) { @@ -146,7 +151,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { } ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); - response.writeShort(index); + response.writeShort(recordIndex); response.writeByte(0); // success sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response); @@ -186,7 +191,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder { response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); response.writeByte(0); // success - sendResponse(channel, PT_APPDATA, index, serviceType, MSG_RESULT_CODE, response); + sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response); } else if (type == MSG_POS_DATA) { -- cgit v1.2.3