diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-13 16:46:42 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-03-13 16:46:42 +1300 |
commit | bb49f1e2c38e23860e87e1801edc456f30165d5f (patch) | |
tree | f68d35cf143a7f68016e937df0bdd920e8e0b3a5 | |
parent | 709b02703cfd974bc17127f3e4683b9d96249eb9 (diff) | |
download | trackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.tar.gz trackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.tar.bz2 trackermap-server-bb49f1e2c38e23860e87e1801edc456f30165d5f.zip |
DM G50 hello message response
-rw-r--r-- | src/org/traccar/protocol/DmtProtocolDecoder.java | 15 | ||||
-rw-r--r-- | test/org/traccar/protocol/DmtProtocolDecoderTest.java | 3 |
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, |