aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index 3d27be9d4..b63385187 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -27,6 +27,7 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
import org.traccar.model.Position;
+import org.traccar.model.WifiAccessPoint;
import java.net.SocketAddress;
import java.text.SimpleDateFormat;
@@ -86,6 +87,25 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
+ private static final Pattern PATTERN_LBS = new PatternBuilder()
+ .expression("[A-Z]{2,3}")
+ .text("AP02,")
+ .expression("[^,]+,") // language
+ .number("[01],") // reply
+ .number("d+,") // cell count
+ .number("(d+),") // mcc
+ .number("(d+),") // mnc
+ .expression("(")
+ .groupBegin()
+ .number("d+|") // lac
+ .number("d+|") // cid
+ .number("d+,") // rssi
+ .groupEnd("+")
+ .expression(")")
+ .number("d+,") // wifi count
+ .expression("(.*)") // wifi
+ .compile();
+
private Boolean decodeOptionalValue(Parser parser, int activeValue) {
int value = parser.nextInt();
if (value != 0) {
@@ -191,6 +211,45 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
return position;
+ } else if (type.equals("AP02")) {
+
+ Parser parser = new Parser(PATTERN_LBS, sentence);
+ if (!parser.matches()) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ getLastLocation(position, null);
+
+ int mcc = parser.nextInt();
+ int mnc = parser.nextInt();
+
+ Network network = new Network();
+
+ for (String cell : parser.next().split(",")) {
+ if (!cell.isEmpty()) {
+ String[] values = cell.split("\\|");
+ network.addCellTower(CellTower.from(
+ mcc, mnc,
+ Integer.parseInt(values[0]),
+ Integer.parseInt(values[1]),
+ Integer.parseInt(values[2])));
+ }
+ }
+
+ for (String wifi : parser.next().split("&")) {
+ if (!wifi.isEmpty()) {
+ String[] values = wifi.split("\\|");
+ network.addWifiAccessPoint(WifiAccessPoint.from(values[1], Integer.parseInt(values[2])));
+ }
+ }
+
+ position.setNetwork(network);
+
+ return position;
+
}
return null;