aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index 68c143257..9aaef9051 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -22,7 +22,10 @@ import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.joda.time.format.ISODateTimeFormat;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
+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;
@@ -54,6 +57,8 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
position.setProtocol(getProtocolName());
position.setValid(true);
+ Network network = new Network();
+
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
String value = entry.getValue().get(0);
switch (entry.getKey()) {
@@ -97,6 +102,23 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
position.setLatitude(Double.parseDouble(location[0]));
position.setLongitude(Double.parseDouble(location[1]));
break;
+ case "cell":
+ String[] cell = value.split(",");
+ if (cell.length > 4) {
+ network.addCellTower(CellTower.from(
+ Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
+ Integer.parseInt(cell[2]), Integer.parseInt(cell[3]), Integer.parseInt(cell[4])));
+ } else {
+ network.addCellTower(CellTower.from(
+ Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
+ Integer.parseInt(cell[2]), Integer.parseInt(cell[3])));
+ }
+ break;
+ case "wifi":
+ String[] wifi = value.split(",");
+ network.addWifiAccessPoint(WifiAccessPoint.from(
+ wifi[0].replace('-', ':'), Integer.parseInt(wifi[1])));
+ break;
case "speed":
position.setSpeed(convertSpeed(Double.parseDouble(value), "kn"));
break;
@@ -143,6 +165,14 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
position.setTime(new Date());
}
+ if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
+ position.setNetwork(network);
+ }
+
+ if (position.getLatitude() == 0 && position.getLongitude() == 0) {
+ getLastLocation(position, position.getDeviceTime());
+ }
+
if (position.getDeviceId() != 0) {
sendResponse(channel, HttpResponseStatus.OK);
return position;