aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-12-14 06:59:53 -0800
committerAnton Tananaev <anton@traccar.org>2022-12-14 06:59:53 -0800
commit64391161c1fb03bd9ff5ea30749b4e00230fa8aa (patch)
tree44ba93ae9f1f2e0058360460fca289189c5116a0 /src/main/java
parenta87c77da9e8d39856e2a16ae3d3aa385e068a1e8 (diff)
downloadtrackermap-server-64391161c1fb03bd9ff5ea30749b4e00230fa8aa.tar.gz
trackermap-server-64391161c1fb03bd9ff5ea30749b4e00230fa8aa.tar.bz2
trackermap-server-64391161c1fb03bd9ff5ea30749b4e00230fa8aa.zip
Handle Teltonika heartbeat
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaFrameDecoder.java4
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java8
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaFrameDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaFrameDecoder.java
index c30fee6e3..3a0962584 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaFrameDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2022 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.
@@ -30,7 +30,7 @@ public class TeltonikaFrameDecoder extends BaseFrameDecoder {
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
while (buf.isReadable() && buf.getByte(buf.readerIndex()) == (byte) 0xff) {
- buf.skipBytes(1);
+ return buf.readRetainedSlice(1);
}
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index c63d74c9c..929eca8aa 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -647,9 +647,11 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
+ private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
- if (buf.getUnsignedShort(0) > 0) {
+ if (buf.readableBytes() == 1 && buf.readUnsignedByte() == 0xff) {
+ return null;
+ } else if (buf.getUnsignedShort(0) > 0) {
parseIdentification(channel, remoteAddress, buf);
} else {
buf.skipBytes(4);
@@ -659,7 +661,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
+ private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.readUnsignedShort(); // length
buf.readUnsignedShort(); // packet id