aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/DmtProtocolDecoder.java15
-rw-r--r--test/org/traccar/protocol/DmtProtocolDecoderTest.java3
2 files changed, 13 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/DmtProtocolDecoder.java b/src/org/traccar/protocol/DmtProtocolDecoder.java
index 74db5a6f7..3739253f0 100644
--- a/src/org/traccar/protocol/DmtProtocolDecoder.java
+++ b/src/org/traccar/protocol/DmtProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,8 +70,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(2); // header
int type = buf.readUnsignedByte();
-
- buf.readUnsignedShort(); // length
+ int length = buf.readUnsignedShort();
if (type == MSG_HELLO) {
@@ -81,8 +80,14 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII));
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
- response.writeInt((int) ((System.currentTimeMillis() - 1356998400000L) / 1000));
- response.writeInt(deviceSession != null ? 0 : 1); // flags
+ if (length == 51) {
+ response.writeByte(0); // reserved
+ response.writeInt(0); // reserved
+ } else {
+ response.writeInt((int) ((System.currentTimeMillis() - 1356998400000L) / 1000));
+ response.writeInt(deviceSession != null ? 0 : 1); // flags
+ }
+
sendResponse(channel, MSG_HELLO_RESPONSE, response);
} else if (type == MSG_COMMIT) {
diff --git a/test/org/traccar/protocol/DmtProtocolDecoderTest.java b/test/org/traccar/protocol/DmtProtocolDecoderTest.java
index 2575d77ed..a83dcafe2 100644
--- a/test/org/traccar/protocol/DmtProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/DmtProtocolDecoderTest.java
@@ -13,6 +13,9 @@ public class DmtProtocolDecoderTest extends ProtocolTest {
DmtProtocolDecoder decoder = new DmtProtocolDecoder(new DmtProtocol());
verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "0255003300001b00003335333232393032373533393235310038393931353030303030303030313330343539340000000403041910780603"));
+
+ verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"025500310038f90100333533333233303831363639373330003839363130313835303031383234383434363330002202010900000000"));
verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,