aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-02-10 22:57:09 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-02-10 22:57:09 -0800
commitf144438bdcf1385d8f3e9dbd42b9b90e28f750e4 (patch)
treef9e4dbdfc2ea5b6daf5d585fc6ac856143430a39 /src/main/java/org/traccar/protocol
parent9f074b062271e5e46612ef0149dd8e2269c22222 (diff)
downloadtrackermap-server-f144438bdcf1385d8f3e9dbd42b9b90e28f750e4.tar.gz
trackermap-server-f144438bdcf1385d8f3e9dbd42b9b90e28f750e4.tar.bz2
trackermap-server-f144438bdcf1385d8f3e9dbd42b9b90e28f750e4.zip
Support wifi networks
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
index 920898039..eac06bbfe 100644
--- a/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -28,6 +28,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;
@@ -139,6 +140,8 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, buf.readUnsignedShort() * 1000);
+ Network network = new Network();
+
while (buf.readableBytes() > 4) {
int subtype = buf.readUnsignedShort();
int length = buf.readUnsignedShort() - 4;
@@ -164,7 +167,6 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
Position.KEY_VIN, buf.readCharSequence(length, StandardCharsets.US_ASCII).toString());
break;
case 0x0020:
- Network network = new Network();
String[] cells = buf.readCharSequence(
length, StandardCharsets.US_ASCII).toString().split("\\+");
for (String cell : cells) {
@@ -173,7 +175,14 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
Integer.parseInt(values[0]), Integer.parseInt(values[1]),
Integer.parseInt(values[2], 16), Integer.parseInt(values[3], 16)));
}
- position.setNetwork(network);
+ break;
+ case 0x0021:
+ String[] points = buf.readCharSequence(
+ length, StandardCharsets.US_ASCII).toString().split("\\+");
+ for (String point : points) {
+ String[] values = point.split("@");
+ network.addWifiAccessPoint(WifiAccessPoint.from(values[0], Integer.parseInt(values[1])));
+ }
break;
default:
buf.skipBytes(length);
@@ -181,6 +190,10 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+
sendResponse(channel, MSG_POSITION_RSP, index, null);
return position;