diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-12 13:49:59 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-12 13:49:59 +1200 |
commit | 69a4af1c2b419fd7cc6356bcc2bf760969a73f95 (patch) | |
tree | 4192ef221be88b024d96422e274836f4c6b33922 /src/org/traccar/protocol/L100FrameDecoder.java | |
parent | 1dc1e06cfd4b7b23775984a254723b2d06b4f1dd (diff) | |
parent | 86ad45c63c9a9e9bee59a8cc621416e1396f9c89 (diff) | |
download | trackermap-server-69a4af1c2b419fd7cc6356bcc2bf760969a73f95.tar.gz trackermap-server-69a4af1c2b419fd7cc6356bcc2bf760969a73f95.tar.bz2 trackermap-server-69a4af1c2b419fd7cc6356bcc2bf760969a73f95.zip |
Merge branch 'master' into netty4
# Conflicts:
# src/org/traccar/protocol/AquilaProtocolDecoder.java
# src/org/traccar/protocol/L100FrameDecoder.java
Diffstat (limited to 'src/org/traccar/protocol/L100FrameDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/L100FrameDecoder.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/L100FrameDecoder.java b/src/org/traccar/protocol/L100FrameDecoder.java index d407ac0b5..b7caa14f4 100644 --- a/src/org/traccar/protocol/L100FrameDecoder.java +++ b/src/org/traccar/protocol/L100FrameDecoder.java @@ -26,22 +26,32 @@ public class L100FrameDecoder extends BaseFrameDecoder { protected Object decode( ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception { - if (buf.readableBytes() < 80) { + if (buf.readableBytes() < 10) { return null; } - int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x02); - if (index == -1) { - index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x04); + int header = buf.getByte(buf.readerIndex()); + boolean obd = header == 'L' || header == 'H'; + + int index; + if (obd) { + index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); + } else { + index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x02); if (index == -1) { - return null; + index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x04); + if (index == -1) { + return null; + } } } index += 2; // checksum - if (buf.readableBytes() >= index - buf.readerIndex()) { - buf.skipBytes(2); // header + if (buf.writerIndex() >= index) { + if (!obd) { + buf.skipBytes(2); // header + } ByteBuf frame = buf.readRetainedSlice(index - buf.readerIndex() - 2); buf.skipBytes(2); // footer return frame; |