locate data
This commit is contained in:
parent
5fd99f890a
commit
439adc0078
1 changed files with 17 additions and 16 deletions
|
@ -1790,10 +1790,10 @@ c3nav = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_no_wifi_count: 0,
|
_no_wifi_count: 0,
|
||||||
_wifi_scan_results: function(data) {
|
_wifi_scan_results: function(peers) {
|
||||||
data = JSON.parse(data);
|
peers = JSON.parse(peers);
|
||||||
|
|
||||||
if (data.length) {
|
if (peers.length) {
|
||||||
c3nav._hasLocationPermission = true;
|
c3nav._hasLocationPermission = true;
|
||||||
} else {
|
} else {
|
||||||
c3nav.hasLocationPermission(true);
|
c3nav.hasLocationPermission(true);
|
||||||
|
@ -1803,21 +1803,22 @@ c3nav = {
|
||||||
if (now-4000 < c3nav._last_wifi_scan) return;
|
if (now-4000 < c3nav._last_wifi_scan) return;
|
||||||
|
|
||||||
if (c3nav.ssids) {
|
if (c3nav.ssids) {
|
||||||
var newdata = [];
|
peers = peers.filter(peer => c3nav.ssids.includes(peer.ssid));
|
||||||
for (var i=0; i<data.length; i++) {
|
|
||||||
// App version < 4.2.6 use level instead fo rssi
|
|
||||||
if (data[i].level !== undefined) {
|
|
||||||
data[i].rssi = data[i].level;
|
|
||||||
delete data[i].level
|
|
||||||
}
|
}
|
||||||
if (c3nav.ssids.indexOf(data[i]['ssid']) >= 0) {
|
for (let peer of peers) {
|
||||||
newdata.push(data[i]);
|
if (peer.level !== undefined) {
|
||||||
|
peer.rssi = peer.level;
|
||||||
|
delete peer.level;
|
||||||
}
|
}
|
||||||
|
if (peer.rtt) {
|
||||||
|
peer.distance = peer.rtt.distance_mm / 1000;
|
||||||
|
peer.distance_sd = peer.rtt.distance_std_dev_mm / 1000;
|
||||||
|
delete peer.rtt;
|
||||||
}
|
}
|
||||||
data = newdata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.length) {
|
|
||||||
|
if (!peers.length) {
|
||||||
if (!c3nav._hasLocationPermission) {
|
if (!c3nav._hasLocationPermission) {
|
||||||
c3nav._set_user_location(null);
|
c3nav._set_user_location(null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1832,7 +1833,7 @@ c3nav = {
|
||||||
}
|
}
|
||||||
c3nav._no_wifi_count = 0;
|
c3nav._no_wifi_count = 0;
|
||||||
|
|
||||||
c3nav_api.post('positioning/locate/', data)
|
c3nav_api.post('positioning/locate/', {peers})
|
||||||
.then(data => c3nav._set_user_location(data.location))
|
.then(data => c3nav._set_user_location(data.location))
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
c3nav._set_user_location(null);
|
c3nav._set_user_location(null);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue