diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-01-12 12:01:10 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-01-12 12:01:10 -0800 |
commit | 82b4ebc742f8801d6a0ef97514f163dd66cb5327 (patch) | |
tree | c9220f9695ee5c68399d7ddfdf8be1d9db6751c2 /src/org | |
parent | a9007f67bc0c579fe7c9bfb856aee9cab89f1ca4 (diff) | |
download | trackermap-server-82b4ebc742f8801d6a0ef97514f163dd66cb5327.tar.gz trackermap-server-82b4ebc742f8801d6a0ef97514f163dd66cb5327.tar.bz2 trackermap-server-82b4ebc742f8801d6a0ef97514f163dd66cb5327.zip |
Support H10 cell and wifi
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/TrvProtocolDecoder.java | 59 |
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; |