diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-16 20:25:20 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-07-16 20:25:20 -0700 |
commit | a92c5786ce74994ad20aee12affd75737a565ba2 (patch) | |
tree | 66f5e092b7712fb521e0bf7dcef0c2173b59251d /src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java | |
parent | 90ddc7b95e3879c20d6d8f7e8b96df87e0ec1f66 (diff) | |
download | trackermap-server-a92c5786ce74994ad20aee12affd75737a565ba2.tar.gz trackermap-server-a92c5786ce74994ad20aee12affd75737a565ba2.tar.bz2 trackermap-server-a92c5786ce74994ad20aee12affd75737a565ba2.zip |
Decode more data
Diffstat (limited to 'src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java b/src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java index b520f6be9..c99d42a59 100644 --- a/src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoFrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2020 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. @@ -31,25 +31,36 @@ public class HuabaoFrameDecoder extends BaseFrameDecoder { return null; } - int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x7e); - if (index != -1) { - ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); - - while (buf.readerIndex() <= index) { - int b = buf.readUnsignedByte(); - if (b == 0x7d) { - int ext = buf.readUnsignedByte(); - if (ext == 0x01) { - result.writeByte(0x7d); - } else if (ext == 0x02) { - result.writeByte(0x7e); + if (buf.getByte(buf.readerIndex()) == '(') { + + int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) ')'); + if (index >= 0) { + return buf.readRetainedSlice(index + 1); + } + + } else { + + int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x7e); + if (index >= 0) { + ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex()); + + while (buf.readerIndex() <= index) { + int b = buf.readUnsignedByte(); + if (b == 0x7d) { + int ext = buf.readUnsignedByte(); + if (ext == 0x01) { + result.writeByte(0x7d); + } else if (ext == 0x02) { + result.writeByte(0x7e); + } + } else { + result.writeByte(b); } - } else { - result.writeByte(b); } + + return result; } - return result; } return null; |