aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-08-31 21:55:27 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-08-31 21:55:27 -0700
commit477280172e0797e5bad041641d1381fee46704f7 (patch)
treee21c37aef07af40f95061d284195b55e9419e8d0
parent9411263d59a053347cae7feb47248b8b8d0c2d62 (diff)
downloadtrackermap-server-477280172e0797e5bad041641d1381fee46704f7.tar.gz
trackermap-server-477280172e0797e5bad041641d1381fee46704f7.tar.bz2
trackermap-server-477280172e0797e5bad041641d1381fee46704f7.zip
Support Teltonika beacon data
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java27
-rw-r--r--src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java3
2 files changed, 28 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 40b769869..e0c51846c 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -43,9 +43,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
private static final int IMAGE_PACKET_MAX = 2048;
- private boolean connectionless;
+ private final boolean connectionless;
private boolean extended;
- private Map<Long, ByteBuf> photos = new HashMap<>();
+ private final Map<Long, ByteBuf> photos = new HashMap<>();
public void setExtended(boolean extended) {
this.extended = extended;
@@ -569,6 +569,29 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
int length = buf.readUnsignedShort();
if (id == 256) {
position.set(Position.KEY_VIN, buf.readSlice(length).toString(StandardCharsets.US_ASCII));
+ } else if (id == 385) {
+ ByteBuf data = buf.readSlice(length);
+ data.readUnsignedByte(); // data part
+ int index = 1;
+ while (data.isReadable()) {
+ int flags = data.readUnsignedByte();
+ if (BitUtil.from(flags, 4) > 0) {
+ position.set("beacon" + index + "Uuid", ByteBufUtil.hexDump(data.readSlice(16)));
+ position.set("beacon" + index + "Major", data.readUnsignedShort());
+ position.set("beacon" + index + "Minor", data.readUnsignedShort());
+ } else {
+ position.set("beacon" + index + "Namespace", ByteBufUtil.hexDump(data.readSlice(10)));
+ position.set("beacon" + index + "Instance", ByteBufUtil.hexDump(data.readSlice(6)));
+ }
+ position.set("beacon" + index + "Rssi", (int) data.readByte());
+ if (BitUtil.check(flags, 1)) {
+ position.set("beacon" + index + "Battery", data.readUnsignedShort() * 0.01);
+ }
+ if (BitUtil.check(flags, 2)) {
+ position.set("beacon" + index + "Temp", data.readUnsignedShort());
+ }
+ index += 1;
+ }
} else {
position.set(Position.PREFIX_IO + id, ByteBufUtil.hexDump(buf.readSlice(length)));
}
diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
index 5b2df38db..62c7f39f8 100644
--- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
@@ -15,6 +15,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"000F313233343536373839303132333435"));
+ verifyPositions(decoder, binary(
+ "00000000000000858e0200000174431aadc100061d888f21000e8a0032002e0c000001810001000000000000000000010181001711210102030405060708090a0b0c0d0e0f10020b010ad000000174431a389100061d888f21000e8a0033002e0d000001810001000000000000000000010181001711210102030405060708090a0b0c0d0e0f10020b010ad2020000492b"));
+
verifyPositions(decoder, false, binary(
"000000000000001C0D01050000001056E924222347455420444154414F524445520D0A0100004990"));