aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/DmtProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-13 16:46:42 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-03-13 16:46:42 +1300
commitbb49f1e2c38e23860e87e1801edc456f30165d5f (patch)
treef68d35cf143a7f68016e937df0bdd920e8e0b3a5 /src/org/traccar/protocol/DmtProtocolDecoder.java
parent709b02703cfd974bc17127f3e4683b9d96249eb9 (diff)
downloadtrackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.tar.gz
trackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.tar.bz2
trackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.zip
DM G50 hello message response
Diffstat (limited to 'src/org/traccar/protocol/DmtProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/DmtProtocolDecoder.java15
1 files changed, 10 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) {