diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2022-02-06 11:04:36 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2022-02-06 11:04:36 -0800 |
commit | 9de6ffeb75a15422e48ad7d9995b6670b336b3ff (patch) | |
tree | 127e35a1ee755601449cc29f682671521606092e /src/main/java/org/traccar/protocol/S168ProtocolDecoder.java | |
parent | 0738af216e7b31926e05d3de64e14e5b7f0b214c (diff) | |
download | trackermap-server-9de6ffeb75a15422e48ad7d9995b6670b336b3ff.tar.gz trackermap-server-9de6ffeb75a15422e48ad7d9995b6670b336b3ff.tar.bz2 trackermap-server-9de6ffeb75a15422e48ad7d9995b6670b336b3ff.zip |
Decode S168 network info
Diffstat (limited to 'src/main/java/org/traccar/protocol/S168ProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/S168ProtocolDecoder.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java b/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java index 685364483..921141698 100644 --- a/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/S168ProtocolDecoder.java @@ -20,7 +20,10 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.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,6 +51,8 @@ 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) { @@ -73,11 +78,32 @@ 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; default: break; } } + if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) { + position.setNetwork(network); + } + return position.getAttributes().containsKey(Position.KEY_SATELLITES) ? position : null; } |