aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-01-24 09:27:14 -0800
committerAnton Tananaev <anton@traccar.org>2023-01-24 09:27:14 -0800
commit3771dd156efb068b2f6ba586ec5b951985c40cc5 (patch)
tree4f30862dc6741ffcc25b55af36e732448a2531fa /src/main/java/org
parent4722f9b6b6489ea7e9dea0c01ae1d7d3044310b5 (diff)
downloadtrackermap-server-3771dd156efb068b2f6ba586ec5b951985c40cc5.tar.gz
trackermap-server-3771dd156efb068b2f6ba586ec5b951985c40cc5.tar.bz2
trackermap-server-3771dd156efb068b2f6ba586ec5b951985c40cc5.zip
Handle new watch format
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index 6fb626d1d..e100d0dc0 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -139,41 +139,45 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
String[] values = parser.next().split(",");
int index = 0;
- Network network = new Network();
-
- int cellCount = Integer.parseInt(values[index++]);
- if (cellCount > 0) {
- index += 1; // timing advance
- int mcc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
- int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
-
- for (int i = 0; i < cellCount; i++) {
- int lac = Integer.parseInt(values[index++]);
- int cid = Integer.parseInt(values[index++]);
- String rssi = values[index++];
- if (!rssi.isEmpty()) {
- network.addCellTower(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(rssi)));
- } else {
- network.addCellTower(CellTower.from(mcc, mnc, lac, cid));
+ if (values.length < 4 || !values[index + 3].startsWith("F")) {
+
+ Network network = new Network();
+
+ int cellCount = Integer.parseInt(values[index++]);
+ if (cellCount > 0) {
+ index += 1; // timing advance
+ int mcc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
+ int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
+
+ for (int i = 0; i < cellCount; i++) {
+ int lac = Integer.parseInt(values[index++]);
+ int cid = Integer.parseInt(values[index++]);
+ String rssi = values[index++];
+ if (!rssi.isEmpty()) {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(rssi)));
+ } else {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid));
+ }
}
}
- }
- if (index < values.length && !values[index].isEmpty()) {
- int wifiCount = Integer.parseInt(values[index++]);
+ if (index < values.length && !values[index].isEmpty()) {
+ int wifiCount = Integer.parseInt(values[index++]);
- for (int i = 0; i < wifiCount; i++) {
- index += 1; // wifi name
- String macAddress = values[index++];
- String rssi = values[index++];
- if (!macAddress.isEmpty() && !macAddress.equals("0") && !rssi.isEmpty()) {
- network.addWifiAccessPoint(WifiAccessPoint.from(macAddress, Integer.parseInt(rssi)));
+ for (int i = 0; i < wifiCount; i++) {
+ index += 1; // wifi name
+ String macAddress = values[index++];
+ String rssi = values[index++];
+ if (!macAddress.isEmpty() && !macAddress.equals("0") && !rssi.isEmpty()) {
+ network.addWifiAccessPoint(WifiAccessPoint.from(macAddress, Integer.parseInt(rssi)));
+ }
}
}
- }
- if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
- position.setNetwork(network);
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+
}
return position;