aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
index ad7dfa886..e85bdf9b3 100644
--- a/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2021 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.
@@ -17,7 +17,8 @@ package org.traccar.protocol;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.DeviceSession;
+import org.traccar.model.CellTower;
+import org.traccar.session.DeviceSession;
import org.traccar.Protocol;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -55,6 +56,12 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN_POSITION = new PatternBuilder()
.text("#")
.number("(?:(dd)|x*)") // cell or voltage
+ .groupBegin()
+ .number("#(d+),") // mcc
+ .number("(d+),") // mnc
+ .number("(x+),") // lac
+ .number("(x+)") // cell id
+ .groupEnd("?")
.text("$GPRMC,")
.number("(dd)(dd)(dd).d+,") // time (hhmmss.sss)
.expression("([AVL]),") // validity
@@ -71,6 +78,12 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
private static final Pattern PATTERN_WIFI = new PatternBuilder()
.text("#")
.number("(?:(dd)|x+)") // cell or voltage
+ .groupBegin()
+ .number("#(d+),") // mcc
+ .number("(d+),") // mnc
+ .number("(x+),") // lac
+ .number("(x+)") // cell id
+ .groupEnd("?")
.text("$WIFI,")
.number("(dd)(dd)(dd).d+,") // time (hhmmss.sss)
.expression("[AVL],") // validity
@@ -168,6 +181,13 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1);
}
+ if (parser.hasNext(4)) {
+ Network network = new Network();
+ network.addCellTower(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextHexInt(), parser.nextHexInt()));
+ position.setNetwork(network);
+ }
+
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
@@ -191,11 +211,16 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextInt() * 0.1);
+ Network network = new Network();
+ if (parser.hasNext(4)) {
+ network.addCellTower(CellTower.from(
+ parser.nextInt(), parser.nextInt(), parser.nextHexInt(), parser.nextHexInt()));
+ }
+
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt());
String[] values = parser.next().split(",");
- Network network = new Network();
for (int i = 0; i < values.length / 2; i++) {
String mac = values[i * 2 + 1].replaceAll("(..)", "$1:").substring(0, 17);
network.addWifiAccessPoint(WifiAccessPoint.from(mac, Integer.parseInt(values[i * 2])));