aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/OsmAndProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-20 06:58:50 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-12-20 06:58:50 +1300
commitcfe0c06a2b067fd2c80275a79c80f3e222fe6006 (patch)
tree3ae525636882fbd5f885b4bcea07489d6e1a564b /src/org/traccar/protocol/OsmAndProtocolDecoder.java
parentf9b786398acee9f73e8591f7b0967be280524045 (diff)
downloadtrackermap-server-cfe0c06a2b067fd2c80275a79c80f3e222fe6006.tar.gz
trackermap-server-cfe0c06a2b067fd2c80275a79c80f3e222fe6006.tar.bz2
trackermap-server-cfe0c06a2b067fd2c80275a79c80f3e222fe6006.zip
Support LBS for OsmAnd protocol
Diffstat (limited to 'src/org/traccar/protocol/OsmAndProtocolDecoder.java')
-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;