aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-02-08 11:29:12 +0800
committerGitHub <noreply@github.com>2017-02-08 11:29:12 +0800
commit4944796891b6416e30c3ee96b4bd03257d9ad8d2 (patch)
tree01aba5ef10912361a8331fa0fd00e692dcce2c8a /src/org
parent141359fd15185f7542d3b0bfea9467902461bd7b (diff)
parentda4aa93919f113c5b9ff9c417dc8db72efea6fd1 (diff)
downloadtrackermap-server-4944796891b6416e30c3ee96b4bd03257d9ad8d2.tar.gz
trackermap-server-4944796891b6416e30c3ee96b4bd03257d9ad8d2.tar.bz2
trackermap-server-4944796891b6416e30c3ee96b4bd03257d9ad8d2.zip
Merge pull request #2881 from gustavofcalmeida/master
Fix MXT protocol response
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index f6c471b19..eaeeacc97 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -42,26 +42,25 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, int device, long id, int crc) {
if (channel != null) {
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_XMODEM, response.toByteBuffer(1, response.readableBytes() - 1)));
- response.writeByte(0x04); // ending
- channel.write(response);
+ Checksum.CRC16_XMODEM, response.toByteBuffer()));
ChannelBuffer encoded = ChannelBuffers.dynamicBuffer();
+ encoded.writeByte(0x01); // header
while (response.readable()) {
int b = response.readByte();
- if (response.readerIndex() != 1 && response.readableBytes() != 0
- && (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13)) {
+ if (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13) {
encoded.writeByte(0x10);
b += 0x20;
}
- response.writeByte(b);
+ encoded.writeByte(b);
}
+ encoded.writeByte(0x04); // ending
+ channel.write(encoded);
}
}