aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/L100FrameDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-12-21 16:54:46 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2018-12-21 16:54:46 -0800
commit0c0df0ff62a4b14aba8ef2ebd8642d1ee3dd4148 (patch)
tree8e13ed7eca0a1e3d5492a516d1f681b6c6200b09 /src/org/traccar/protocol/L100FrameDecoder.java
parente8e73376eac069134077a5be7978d9a3619913b3 (diff)
downloadtrackermap-server-0c0df0ff62a4b14aba8ef2ebd8642d1ee3dd4148.tar.gz
trackermap-server-0c0df0ff62a4b14aba8ef2ebd8642d1ee3dd4148.tar.bz2
trackermap-server-0c0df0ff62a4b14aba8ef2ebd8642d1ee3dd4148.zip
Support PT100 protocol
Diffstat (limited to 'src/org/traccar/protocol/L100FrameDecoder.java')
-rw-r--r--src/org/traccar/protocol/L100FrameDecoder.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/L100FrameDecoder.java b/src/org/traccar/protocol/L100FrameDecoder.java
index b7caa14f4..9e08120dd 100644
--- a/src/org/traccar/protocol/L100FrameDecoder.java
+++ b/src/org/traccar/protocol/L100FrameDecoder.java
@@ -20,6 +20,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import org.traccar.BaseFrameDecoder;
+import java.nio.charset.StandardCharsets;
+
public class L100FrameDecoder extends BaseFrameDecoder {
@Override
@@ -30,6 +32,15 @@ public class L100FrameDecoder extends BaseFrameDecoder {
return null;
}
+ if (buf.getCharSequence(buf.readerIndex(), 4, StandardCharsets.US_ASCII).equals("ATL,")) {
+ return decodeNew(buf);
+ } else {
+ return decodeOld(buf);
+ }
+ }
+
+ private Object decodeOld(ByteBuf buf) {
+
int header = buf.getByte(buf.readerIndex());
boolean obd = header == 'L' || header == 'H';
@@ -38,9 +49,9 @@ public class L100FrameDecoder extends BaseFrameDecoder {
index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*');
} else {
index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x02);
- if (index == -1) {
+ if (index < 0) {
index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x04);
- if (index == -1) {
+ if (index < 0) {
return null;
}
}
@@ -60,4 +71,20 @@ public class L100FrameDecoder extends BaseFrameDecoder {
return null;
}
+ private Object decodeNew(ByteBuf buf) {
+
+ int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '@');
+ if (index < 0) {
+ return null;
+ }
+
+ if (buf.writerIndex() >= index + 1) {
+ ByteBuf frame = buf.readRetainedSlice(index - buf.readerIndex());
+ buf.skipBytes(1); // delimiter
+ return frame;
+ }
+
+ return null;
+ }
+
}