aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MxtProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/MxtProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index c9eba5bed..eaeeacc97 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,26 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, int device, long id, int crc) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
- response.writeByte(0x01); // header
+ ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
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())));
- 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 (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13) {
+ encoded.writeByte(0x10);
+ b += 0x20;
+ }
+ encoded.writeByte(b);
+ }
+ encoded.writeByte(0x04); // ending
+ channel.write(encoded);
}
}