diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-07 08:23:19 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-02-07 08:23:19 +1300 |
commit | 340a79599b162d514a67f570b9a6501c9bdf0304 (patch) | |
tree | 9dd5c10319e2c65cd58327a98b531e6f29d096d1 /src/org | |
parent | fb8680cda73b4036d0b41eecd0e5f0b488424244 (diff) | |
download | trackermap-server-340a79599b162d514a67f570b9a6501c9bdf0304.tar.gz trackermap-server-340a79599b162d514a67f570b9a6501c9bdf0304.tar.bz2 trackermap-server-340a79599b162d514a67f570b9a6501c9bdf0304.zip |
Fix MXT response (fix #2847)
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/MxtProtocolDecoder.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java index c9eba5bed..f6c471b19 100644 --- a/src/org/traccar/protocol/MxtProtocolDecoder.java +++ b/src/org/traccar/protocol/MxtProtocolDecoder.java @@ -27,6 +27,7 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.nio.ByteOrder; public class MxtProtocolDecoder extends BaseProtocolDecoder { @@ -40,16 +41,27 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder { private static void sendResponse(Channel channel, int device, long id, int crc) { if (channel != null) { - ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0); response.writeByte(0x01); // header response.writeByte(device); response.writeByte(MSG_ACK); response.writeInt((int) id); response.writeShort(crc); response.writeShort(Checksum.crc16( - Checksum.CRC16_CCITT_FALSE, response.toByteBuffer(0, response.readableBytes()))); + Checksum.CRC16_XMODEM, response.toByteBuffer(1, response.readableBytes() - 1))); response.writeByte(0x04); // ending channel.write(response); + + ChannelBuffer encoded = ChannelBuffers.dynamicBuffer(); + while (response.readable()) { + int b = response.readByte(); + if (response.readerIndex() != 1 && response.readableBytes() != 0 + && (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13)) { + encoded.writeByte(0x10); + b += 0x20; + } + response.writeByte(b); + } } } |