aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java
diff options
context:
space:
mode:
authorcasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
committercasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
commit7338b8730949ed027b3f8b31d7dca20687ebbb8b (patch)
treec2d171e6121818ab511460a786f69aab97a2a628 /src/main/java/org/traccar/protocol/S168ProtocolDecoder.java
parentcdecd3fa4427a382c0b09f8ad9d69ec14388960a (diff)
parent85501f9cf4918d5eee345f83aed7a31eecb26b8d (diff)
downloadtrackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.gz
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.bz2
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.zip
Merge branch 'master' into develop
Diffstat (limited to 'src/main/java/org/traccar/protocol/S168ProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/S168ProtocolDecoder.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java b/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java
index 71aff1a65..cf665c6ba 100644
--- a/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 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,10 +17,13 @@ package org.traccar.protocol;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.DeviceSession;
+import org.traccar.session.DeviceSession;
import org.traccar.Protocol;
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.DateFormat;
@@ -48,9 +51,14 @@ public class S168ProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ Network network = new Network();
+
String content = values[4];
String[] fragments = content.split(";");
for (String fragment : fragments) {
+ if (fragment.isEmpty()) {
+ continue;
+ }
int dataIndex = fragment.indexOf(':');
String type = fragment.substring(0, dataIndex);
@@ -70,12 +78,44 @@ public class S168ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(Integer.parseInt(values[index++]));
position.setAltitude(Integer.parseInt(values[index++]));
break;
+ case "CELL":
+ int cellCount = Integer.parseInt(values[index++]);
+ int mcc = Integer.parseInt(values[index++], 16);
+ int mnc = Integer.parseInt(values[index++], 16);
+ for (int i = 0; i < cellCount; i++) {
+ network.addCellTower(CellTower.from(
+ mcc, mnc, Integer.parseInt(values[index++], 16), Integer.parseInt(values[index++], 16),
+ Integer.parseInt(values[index++], 16)));
+ }
+ break;
+ case "WIFI":
+ int wifiCount = Integer.parseInt(values[index++]);
+ for (int i = 0; i < wifiCount; i++) {
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ values[index++].replace('-', ':'), Integer.parseInt(values[index++])));
+ }
+ break;
+ case "STATUS":
+ position.set(Position.KEY_BATTERY_LEVEL, Integer.parseInt(values[index++]));
+ position.set(Position.KEY_RSSI, Integer.parseInt(values[index++]));
+ break;
default:
break;
}
}
- return position.getAttributes().containsKey(Position.KEY_SATELLITES) ? position : null;
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+ if (!position.hasAttribute(Position.KEY_SATELLITES)) {
+ getLastLocation(position, null);
+ }
+
+ if (position.getNetwork() != null || !position.getAttributes().isEmpty()) {
+ return position;
+ } else {
+ return null;
+ }
}
}