diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-01-23 02:01:58 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-01-23 02:01:58 +1300 |
commit | e2e0501877c501cdf09158684df046e4e4c41734 (patch) | |
tree | fbe45457d71eb41a83047045c7faa3a2e27b61b9 /src/org/traccar | |
parent | 2da3d337175fb25d9715b579fa950e75d82fa5ee (diff) | |
download | traccar-server-e2e0501877c501cdf09158684df046e4e4c41734.tar.gz traccar-server-e2e0501877c501cdf09158684df046e4e4c41734.tar.bz2 traccar-server-e2e0501877c501cdf09158684df046e4e4c41734.zip |
Repond with device serial number (fix #3704)
Diffstat (limited to 'src/org/traccar')
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index d6cc2fa86..e11a6580b 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -47,8 +47,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private boolean forceTimeZone = false; private final TimeZone timeZone = TimeZone.getTimeZone("UTC"); - private int serverIndex; - private final Map<Integer, ChannelBuffer> photos = new HashMap<>(); public Gt06ProtocolDecoder(Gt06Protocol protocol) { @@ -172,7 +170,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } } - private void sendResponse(Channel channel, boolean extended, int type, ChannelBuffer content) { + private void sendResponse(Channel channel, boolean extended, int type, int index, ChannelBuffer content) { if (channel != null) { ChannelBuffer response = ChannelBuffers.dynamicBuffer(); int length = 5 + (content != null ? content.readableBytes() : 0); @@ -187,7 +185,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { if (content != null) { response.writeBytes(content); } - response.writeShort(++serverIndex); + response.writeShort(index); response.writeShort(Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(2, response.writerIndex() - 2))); response.writeByte('\r'); response.writeByte('\n'); // ending @@ -201,7 +199,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { content.writeInt(pictureId); content.writeInt(photo.writerIndex()); content.writeShort(Math.min(photo.writableBytes(), 1024)); - sendResponse(channel, false, MSG_X1_PHOTO_DATA, content); + sendResponse(channel, false, MSG_X1_PHOTO_DATA, 0, content); } private boolean decodeGps(Position position, ChannelBuffer buf, boolean hasLength) { @@ -410,7 +408,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } if (getDeviceSession(channel, remoteAddress, imei) != null) { - sendResponse(channel, false, type, null); + sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null); } } else if (type == MSG_HEARTBEAT) { @@ -425,7 +423,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_IGNITION, BitUtil.check(status, 1)); position.set(Position.KEY_CHARGE, BitUtil.check(status, 2)); - sendResponse(channel, false, type, null); + sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null); return position; @@ -436,7 +434,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { content.writeByte(response.length()); content.writeInt(0); content.writeBytes(response.getBytes(StandardCharsets.US_ASCII)); - sendResponse(channel, true, MSG_ADDRESS_RESPONSE, content); + sendResponse(channel, true, MSG_ADDRESS_RESPONSE, 0, content); } else if (type == MSG_TIME_REQUEST) { @@ -448,7 +446,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { content.writeByte(calendar.get(Calendar.HOUR_OF_DAY)); content.writeByte(calendar.get(Calendar.MINUTE)); content.writeByte(calendar.get(Calendar.SECOND)); - sendResponse(channel, false, MSG_TIME_REQUEST, content); + sendResponse(channel, false, MSG_TIME_REQUEST, 0, content); } else if (type == MSG_X1_GPS) { @@ -618,7 +616,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(dataLength); if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) { - sendResponse(channel, false, type, null); + sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null); } return null; @@ -632,7 +630,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_GEOFENCE, buf.readUnsignedByte()); } - sendResponse(channel, false, type, null); + sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null); return position; } @@ -751,7 +749,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(buf.readUnsignedByte()); // reserved extension - sendResponse(channel, true, type, null); + sendResponse(channel, true, type, buf.getShort(buf.writerIndex() - 6), null); return position; |