aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/SuntechFrameDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/SuntechFrameDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/SuntechFrameDecoder.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/SuntechFrameDecoder.java b/src/main/java/org/traccar/protocol/SuntechFrameDecoder.java
index de8de17f0..7b8337468 100644
--- a/src/main/java/org/traccar/protocol/SuntechFrameDecoder.java
+++ b/src/main/java/org/traccar/protocol/SuntechFrameDecoder.java
@@ -32,13 +32,24 @@ public class SuntechFrameDecoder extends BaseFrameDecoder {
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- int delimiterIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\r');
- while (delimiterIndex > 0) {
- if (delimiterIndex + 1 < buf.writerIndex() && buf.getByte(delimiterIndex + 1) == '\n') {
- delimiterIndex = buf.indexOf(delimiterIndex + 1, buf.writerIndex(), (byte) '\r');
- } else {
- return readFrame(buf, delimiterIndex);
+ if (buf.getByte(buf.readerIndex()) == (byte) 0x81) {
+
+ int length = 1 + 2 + buf.getShort(buf.readerIndex() + 1);
+ if (buf.readableBytes() >= length) {
+ return buf.readRetainedSlice(length);
}
+
+ } else {
+
+ int delimiterIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\r');
+ while (delimiterIndex > 0) {
+ if (delimiterIndex + 1 < buf.writerIndex() && buf.getByte(delimiterIndex + 1) == '\n') {
+ delimiterIndex = buf.indexOf(delimiterIndex + 1, buf.writerIndex(), (byte) '\r');
+ } else {
+ return readFrame(buf, delimiterIndex);
+ }
+ }
+
}
return null;