diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-12 10:54:28 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-05-12 10:54:28 -0700 |
commit | d07cf0b77fc020a68472a48d3941975491552324 (patch) | |
tree | 8103ca55ddedbd3e9353c4fb879f6d2d520f37e2 /src/main/java | |
parent | d69822e05509d89bbec99a5045fbbdaf4757c716 (diff) | |
download | trackermap-server-d07cf0b77fc020a68472a48d3941975491552324.tar.gz trackermap-server-d07cf0b77fc020a68472a48d3941975491552324.tar.bz2 trackermap-server-d07cf0b77fc020a68472a48d3941975491552324.zip |
Add ACK response message
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java index 68ebe39a2..51b32ae3e 100644 --- a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java @@ -17,11 +17,14 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.NetworkMessage; import org.traccar.Protocol; import org.traccar.helper.BitUtil; +import org.traccar.helper.Checksum; import org.traccar.helper.UnitsConverter; import org.traccar.model.CellTower; import org.traccar.model.Network; @@ -38,6 +41,7 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder { } public static final int MSG_DATA = 0x01; + public static final int MSG_RESPONSE = 0x7F; private String decodeAlarm(int code) { if (BitUtil.check(code, 0)) { @@ -68,7 +72,26 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder { ByteBuf buf = (ByteBuf) msg; buf.readUnsignedByte(); // header - buf.readUnsignedByte(); // properties + + if (BitUtil.check(buf.readUnsignedByte(), 4) && channel != null) { + + ByteBuf content = Unpooled.buffer(); + content.writeByte(MSG_RESPONSE); + content.writeByte(1); // key length + content.writeByte(0); // success + + ByteBuf response = Unpooled.buffer(); + response.writeByte(0xAB); // header + response.writeByte(0); // properties + response.writeShortLE(3); + response.writeShortLE(Checksum.crc16(Checksum.CRC16_XMODEM, content.nioBuffer())); + response.writeShortLE(0); // index + response.writeBytes(content); + content.release(); + + channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); + } + buf.readUnsignedShortLE(); // length buf.readUnsignedShortLE(); // checksum buf.readUnsignedShortLE(); // index |