aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-04-18 15:26:22 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-04-18 15:26:22 +1200
commit053e03307f851f3d990caf8ba95dad4ea8836977 (patch)
tree5785ffd36647c28261b95bce725000b2d2bd893f
parent48268488c8fbd12e2e177e57dc20cb1d011879d9 (diff)
downloadtrackermap-server-053e03307f851f3d990caf8ba95dad4ea8836977.tar.gz
trackermap-server-053e03307f851f3d990caf8ba95dad4ea8836977.tar.bz2
trackermap-server-053e03307f851f3d990caf8ba95dad4ea8836977.zip
Atrack frame decoder to handle text format
-rw-r--r--src/org/traccar/protocol/AtrackFrameDecoder.java4
-rw-r--r--test/org/traccar/protocol/AtrackFrameDecoderTest.java4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/AtrackFrameDecoder.java b/src/org/traccar/protocol/AtrackFrameDecoder.java
index ce4a9a65f..224679bde 100644
--- a/src/org/traccar/protocol/AtrackFrameDecoder.java
+++ b/src/org/traccar/protocol/AtrackFrameDecoder.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.
@@ -37,7 +37,7 @@ public class AtrackFrameDecoder extends FrameDecoder {
return buf.readBytes(KEEPALIVE_LENGTH);
}
- } else if (buf.getUnsignedShort(buf.readerIndex()) == 0x4050) {
+ } else if (buf.getUnsignedShort(buf.readerIndex()) == 0x4050 && buf.getByte(buf.readerIndex() + 2) != ',') {
if (buf.readableBytes() > 6) {
int length = buf.getUnsignedShort(buf.readerIndex() + 4) + 4 + 2;
diff --git a/test/org/traccar/protocol/AtrackFrameDecoderTest.java b/test/org/traccar/protocol/AtrackFrameDecoderTest.java
index 9db4fd052..52ac18026 100644
--- a/test/org/traccar/protocol/AtrackFrameDecoderTest.java
+++ b/test/org/traccar/protocol/AtrackFrameDecoderTest.java
@@ -13,6 +13,10 @@ public class AtrackFrameDecoderTest extends ProtocolTest {
AtrackFrameDecoder decoder = new AtrackFrameDecoder();
assertEquals(
+ binary("40502c373542332c3132302c37393737392c3335383930313034383039313535342c32303138303431323134323531342c32303138303431323134323531342c32303138303431333030303635352c31363432333338392c34383137383730302c3130382c322c362e352c392c302c302c302c302c302c323030302c323030302c1a0d0a"),
+ decoder.decode(null, null, binary("40502c373542332c3132302c37393737392c3335383930313034383039313535342c32303138303431323134323531342c32303138303431323134323531342c32303138303431333030303635352c31363432333338392c34383137383730302c3130382c322c362e352c392c302c302c302c302c302c323030302c323030302c1a0d0a")));
+
+ assertEquals(
binary("244F4B0D0A"),
decoder.decode(null, null, binary("244F4B0D0A")));