aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2023-09-13 06:49:25 -0700
committerGitHub <noreply@github.com>2023-09-13 06:49:25 -0700
commit7b4d45cc476b80d02a4bbf4bc3a2b6f09fe9c7c3 (patch)
treee37ec8a040c4eea4ab8575bd67f5643df23b57b5
parente000421d9e67960d28666471bf8ea8c7b629dd9d (diff)
parent2ac6fb3f0d6827733724d3d483d87a3ace0b839f (diff)
downloadtrackermap-server-7b4d45cc476b80d02a4bbf4bc3a2b6f09fe9c7c3.tar.gz
trackermap-server-7b4d45cc476b80d02a4bbf4bc3a2b6f09fe9c7c3.tar.bz2
trackermap-server-7b4d45cc476b80d02a4bbf4bc3a2b6f09fe9c7c3.zip
Merge pull request #5172 from berghdavid/master
Add Meitrack WiFi Aps, celltowers and network info
-rw-r--r--src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java31
-rw-r--r--src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java3
2 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
index 0f0d22021..8a1e14834 100644
--- a/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
@@ -30,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;
@@ -394,6 +396,8 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ Network network = new Network();
+
buf.readUnsignedShortLE(); // length
buf.readUnsignedShortLE(); // index
@@ -537,6 +541,27 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int id = extension ? buf.readUnsignedShort() : buf.readUnsignedByte();
int length = buf.readUnsignedByte();
switch (id) {
+ case 0x1D:
+ case 0x1E:
+ case 0x1F:
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ String wifiMac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
+ network.addWifiAccessPoint(WifiAccessPoint.from(wifiMac.substring(0, wifiMac.length() - 1),
+ buf.readShortLE()));
+ break;
+ case 0x0E:
+ case 0x0F:
+ case 0x10:
+ case 0x12:
+ case 0x13:
+ network.addCellTower(CellTower.from(buf.readUnsignedShortLE(), buf.readUnsignedShortLE(),
+ buf.readUnsignedShortLE(), buf.readUnsignedIntLE(), buf.readShortLE()));
+ break;
case 0x2A:
case 0x2B:
case 0x2C:
@@ -548,6 +573,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // label
position.set(Position.PREFIX_TEMP + (id - 0x2A), buf.readShortLE() * 0.01);
break;
+ case 0x4B:
+ buf.skipBytes(length); // network information
+ break;
case 0xFE31:
buf.readUnsignedByte(); // alarm protocol
buf.readUnsignedByte(); // alarm type
@@ -570,6 +598,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
positions.add(position);
}
diff --git a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
index 8d2aee501..91dcf0386 100644
--- a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java
@@ -15,6 +15,9 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
"2424683136342C3836363334343035333039353238322C4343452C000000000100820018000505000600070B14001500080800000900000A00000B00001606001A0000402300FE90000006022E79570103E55CCC0604E1FDB32B0CC32C00000D58EB02001C01000000050E0CCC010000B627BF11000000004B1001010D475052532847534D2039303029FEA50601FFFFFF7FFFFEA80701010258023800FEB20501010000002A41360D0A"),
"battery2Level", 88);
+ verifyPositions(decoder, binary(
+ "2424533232312c3836323331313036323737393431362c4343452c000000000100bb001c0006012305000600071f1500fe6961050800000900000a00000b00001aca000702a72c52030340a0c90004f3408b2c0ca80100000d238d08001c01000000fe37000000000a0e0cf00001002700167aa601a0ff1d082abd890a491cd2ff1e0828bd890a491cd2ff1f0842490f526db0caff20083c286d5b082cc9ff21083e286d5b082cc9ff2208ac233fc0d2e0c7ff2308b0411d64d9d5c7ff2408ae233fc0d496c3ff4b150101124c54452845555452414e2d42414e443230292a38420d0a"));
+
verifyAttribute(decoder, binary(
"2424593434312c3836353431333035303839313733372c4343452c00000000030088001800050501061607191400150008080000098e000a05000b0c001608001a0000402300fe9000000602c3fe5ffe03e22a1f0904e6688d2b0cd94002000d5f6f03001c01000000050e0cf901010032700298c80899ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb205010000000083001700050501061607191400150008080000098e000a05000b0c001608001a0000405100fe9000000502c3fe5ffe03e22a1f0904e6688d2b0cd94002000d606f0300050e0cf901010032700298c80899ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb205010000000088001800050501061607151400150008080000098e000a05000b0c001607001a0000402300fe9000000602c3fe5ffe03e22a1f0904f0688d2b0cd94002000d696f03001c01000000050e0cf901010032700298c80897ff4b16010113464444204c5445284c54452042414e44203329fea50601ffffff7ffffea807024d0000000000feb20501000000002a36320d0a"),
Position.KEY_BATTERY_LEVEL, 77);