From e2a40de5021419222bcfa224e3543881235be7db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 11 Feb 2016 21:37:54 +1100 Subject: Add new Castel response message --- src/org/traccar/protocol/CastelProtocolDecoder.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index 4b8f3b716..209862d1d 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -134,6 +134,24 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { if (type == 0x2001) { + if (channel != null) { + int length = 2 + 2 + id.readableBytes() + 2 + 4 + 8 + 2 + 2; + + ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length); + response.writeByte('@'); response.writeByte('@'); + response.writeShort(length); + response.writeBytes(id); + response.writeShort(ChannelBuffers.swapShort((short) 0x1001)); + response.writeInt((int) (System.currentTimeMillis() / 1000)); + for (int i = 0; i < 8; i++) { + response.writeByte(0xff); + } + response.writeShort( + Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex()))); + response.writeByte(0x0D); response.writeByte(0x0A); + channel.write(response, remoteAddress); + } + buf.readUnsignedInt(); // index buf.readUnsignedInt(); // unix time buf.readUnsignedByte(); -- cgit v1.2.3