aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-13 09:41:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-13 09:41:37 +1300
commit0bbf4169c0b0ebd0cc5797d756350f7a7e57831a (patch)
treee3552808edc064c1d5b2dfb1adf06023c7d0b9fa /src
parent4e05ed1fe9a3de0ac16e4a03970a1b38a2bda318 (diff)
downloadtrackermap-server-0bbf4169c0b0ebd0cc5797d756350f7a7e57831a.tar.gz
trackermap-server-0bbf4169c0b0ebd0cc5797d756350f7a7e57831a.tar.bz2
trackermap-server-0bbf4169c0b0ebd0cc5797d756350f7a7e57831a.zip
Add new format to Totem frame decoder
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/TotemFrameDecoder.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/TotemFrameDecoder.java b/src/org/traccar/protocol/TotemFrameDecoder.java
index d6a456850..83c328173 100644
--- a/src/org/traccar/protocol/TotemFrameDecoder.java
+++ b/src/org/traccar/protocol/TotemFrameDecoder.java
@@ -39,7 +39,15 @@ public class TotemFrameDecoder extends FrameDecoder {
buf.readerIndex(beginIndex);
}
- int length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 2, Charset.defaultCharset()), 16);
+ int length;
+
+ int flagIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("AA"));
+ if (flagIndex != -1 && flagIndex - beginIndex == 6) {
+ length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 4, Charset.defaultCharset()));
+ } else {
+ length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 2, Charset.defaultCharset()), 16);
+ }
+
if (length <= buf.readableBytes()) {
return buf.readBytes(length);
}