aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-03-06 15:34:21 -0800
committerAnton Tananaev <anton@traccar.org>2022-03-06 15:34:21 -0800
commit90dd949c149c4acf9bc383dd019a595808be928e (patch)
tree638e94a0c768f49cc90b06d0a18ca1bb1027d95e
parent09ee3fb9ac865d88f1966cd67fcba67d3c69e390 (diff)
downloadtrackermap-server-90dd949c149c4acf9bc383dd019a595808be928e.tar.gz
trackermap-server-90dd949c149c4acf9bc383dd019a595808be928e.tar.bz2
trackermap-server-90dd949c149c4acf9bc383dd019a595808be928e.zip
Decode TK419-S cell and wifi
-rw-r--r--src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java46
1 files changed, 33 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java b/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java
index 9856ad999..592e5a56c 100644
--- a/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -31,6 +31,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.nio.charset.StandardCharsets;
@@ -192,50 +193,69 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, position.getDeviceTime());
}
+ Network network = new Network();
+
+ int mcc = 0;
+ int mnc = 0;
if (BitUtil.check(flags, 1)) {
- position.setNetwork(new Network(CellTower.from(
- buf.readUnsignedShort(), buf.readUnsignedShort(),
- buf.readUnsignedShort(), buf.readUnsignedInt(), buf.readUnsignedByte())));
+ mcc = buf.readUnsignedShort();
+ mnc = buf.readUnsignedShort();
+ network.addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedInt(), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 2)) {
- buf.skipBytes(7); // bsid1
+ network.addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedInt(), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 3)) {
- buf.skipBytes(7); // bsid2
+ network.addCellTower(CellTower.from(
+ mcc, mnc, buf.readUnsignedShort(), buf.readUnsignedInt(), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 4)) {
- buf.skipBytes(7); // bss0
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 5)) {
- buf.skipBytes(7); // bss1
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 6)) {
- buf.skipBytes(7); // bss2
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ mac.substring(0, mac.length() - 1), buf.readUnsignedByte()));
}
if (BitUtil.check(flags, 7)) {
buf.readUnsignedByte(); // radio access technology
int count = buf.readUnsignedByte();
+ int lac = 0;
if (count > 0) {
- buf.readUnsignedShort(); // mcc
- buf.readUnsignedShort(); // mnc
- buf.readUnsignedShort(); // lac
+ mcc = buf.readUnsignedShort();
+ mnc = buf.readUnsignedShort();
+ lac = buf.readUnsignedShort(); // lac
buf.readUnsignedShort(); // tac
buf.readUnsignedInt(); // cid
buf.readUnsignedShort(); // ta
}
for (int i = 0; i < count; i++) {
- buf.readUnsignedShort(); // physical cid
+ int cid = buf.readUnsignedShort(); // physical cid
buf.readUnsignedShort(); // e-arfcn
- buf.readUnsignedByte(); // rssi
+ int rssi = buf.readUnsignedByte();
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid, rssi));
}
}
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+
if (type == MSG_WARNING) {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));