aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-02-11 21:37:54 +1100
committerAnton Tananaev <anton.tananaev@gmail.com>2016-02-11 21:37:54 +1100
commite2a40de5021419222bcfa224e3543881235be7db (patch)
tree2b4894f7efe132be5683a9c4c43cfdc6ae865d56
parent3884c75ab3849cdb7b2a86ff7fa64c1c22df4ad2 (diff)
downloadtraccar-server-e2a40de5021419222bcfa224e3543881235be7db.tar.gz
traccar-server-e2a40de5021419222bcfa224e3543881235be7db.tar.bz2
traccar-server-e2a40de5021419222bcfa224e3543881235be7db.zip
Add new Castel response message
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java18
1 files changed, 18 insertions, 0 deletions
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();