aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/L100FrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-11 05:49:35 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-11 05:49:35 +1200
commit9cbd8fafc312996b9b5dae68b6c3ecf68d8facf0 (patch)
tree0c8c863e145d688b7885235aeb27b170f4644617 /src/org/traccar/protocol/L100FrameDecoder.java
parent77f5a12b9c50cdf317528a8e1569c3cf47b251f4 (diff)
downloadtrackermap-server-9cbd8fafc312996b9b5dae68b6c3ecf68d8facf0.tar.gz
trackermap-server-9cbd8fafc312996b9b5dae68b6c3ecf68d8facf0.tar.bz2
trackermap-server-9cbd8fafc312996b9b5dae68b6c3ecf68d8facf0.zip
Implement Atlanta OBD protocol
Diffstat (limited to 'src/org/traccar/protocol/L100FrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/L100FrameDecoder.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/org/traccar/protocol/L100FrameDecoder.java b/src/org/traccar/protocol/L100FrameDecoder.java
index 98c2f9768..c8a520772 100644
--- a/src/org/traccar/protocol/L100FrameDecoder.java
+++ b/src/org/traccar/protocol/L100FrameDecoder.java
@@ -26,22 +26,32 @@ public class L100FrameDecoder extends FrameDecoder {
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ChannelBuffer 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
+ }
ChannelBuffer frame = buf.readBytes(index - buf.readerIndex() - 2);
buf.skipBytes(2); // footer
return frame;