mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-28 17:12:22 +00:00
Compare commits
1 Commits
1a3955554a
...
staging-WI
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fd8014f11 |
@@ -4,19 +4,19 @@ let fs = require("fs");
|
||||
let ubus = require('ubus').connect();
|
||||
|
||||
let gps_info = ubus.call('gps', 'info');
|
||||
let latitude = gps_info.latitude ?? 0;
|
||||
let longitude = gps_info.longitude ?? 0;
|
||||
let latitude = gps_info.latitude || 0;
|
||||
let longitude = gps_info.longitude || 0;
|
||||
|
||||
// afc-location.json file content
|
||||
let afc_location = {};
|
||||
afc_location.location_type = "ellipse";
|
||||
afc_location.location = longitude + ":" + latitude ;
|
||||
afc_location.height = gps_info.elevation ?? 0;
|
||||
afc_location.height = gps_info.elevation || 0;
|
||||
afc_location.height_type = "AMSL";
|
||||
afc_location.major_axis = gps_info.major_axis ?? 0;
|
||||
afc_location.minor_axis = gps_info.minor_axis ?? 0;
|
||||
afc_location.orientation = gps_info.major_orientation ?? 0;
|
||||
afc_location.vertical_tolerance = gps_info.vdop ?? 0;
|
||||
afc_location.major_axis = int(gps_info.major_axis) || 1;
|
||||
afc_location.minor_axis = int(gps_info.minor_axis) || 1;
|
||||
afc_location.orientation = gps_info.major_orientation || 0;
|
||||
afc_location.vertical_tolerance = int(gps_info.vdop) || 1;
|
||||
|
||||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
||||
afc_location_json.write(afc_location);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
let libubus = require("ubus");
|
||||
import { open, readfile } from "fs";
|
||||
import { open, readfile, writefile } from "fs";
|
||||
import { wdev_create, wdev_remove, is_equal, vlist_new, phy_is_fullmac, phy_open } from "common";
|
||||
|
||||
let uci = require('uci').cursor();
|
||||
let ubus = libubus.connect(null, 60);
|
||||
|
||||
hostapd.data.config = {};
|
||||
@@ -893,10 +894,21 @@ return {
|
||||
hostapd.ubus.disconnect();
|
||||
},
|
||||
afc_request: function(iface, data) {
|
||||
let ret = ubus.call("afc", "request", { data });
|
||||
if (type(ret) != "object")
|
||||
return;
|
||||
return ret.data;
|
||||
let wireless_config = uci.get_all('wireless');
|
||||
for (let l, afc_server in wireless_config) {
|
||||
if (afc_server['.type'] == 'afc-server' && afc_server.url && data) {
|
||||
hostapd.printf(`Sending AFC request: ${data}`);
|
||||
writefile("/tmp/afc-request.json", data);
|
||||
|
||||
system(`curl -s -X POST ${afc_server.url} -H \'accept: \*\/\*\' -H \'Authorization: Bearer ${afc_server.access_token}\' -H \'Content-Type: application/json\' -d \'${data}\' --output /tmp/afc-response.json`);
|
||||
|
||||
let afc_response = (readfile("/tmp/afc-response.json"));
|
||||
if (afc_response)
|
||||
return afc_response;
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
bss_add: function(name, obj) {
|
||||
bss_event("add", name);
|
||||
|
||||
@@ -4,19 +4,19 @@ let fs = require("fs");
|
||||
let ubus = require('ubus').connect();
|
||||
|
||||
let gps_info = ubus.call('gps', 'info');
|
||||
let latitude = gps_info.latitude ?? 0;
|
||||
let longitude = gps_info.longitude ?? 0;
|
||||
let latitude = gps_info.latitude || 0;
|
||||
let longitude = gps_info.longitude || 0;
|
||||
|
||||
// afc-location.json file content
|
||||
let afc_location = {};
|
||||
afc_location.location_type = "ellipse";
|
||||
afc_location.location = longitude + ":" + latitude ;
|
||||
afc_location.height = gps_info.elevation ?? 0;
|
||||
afc_location.height = gps_info.elevation || 0;
|
||||
afc_location.height_type = "AMSL";
|
||||
afc_location.major_axis = gps_info.major_axis ?? 0;
|
||||
afc_location.minor_axis = gps_info.minor_axis ?? 0;
|
||||
afc_location.orientation = gps_info.major_orientation ?? 0;
|
||||
afc_location.vertical_tolerance = gps_info.vdop ?? 0;
|
||||
afc_location.major_axis = int(gps_info.major_axis) || 1;
|
||||
afc_location.minor_axis = int(gps_info.minor_axis) || 1;
|
||||
afc_location.orientation = gps_info.major_orientation || 0;
|
||||
afc_location.vertical_tolerance = int(gps_info.vdop) || 1;
|
||||
|
||||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
||||
afc_location_json.write(afc_location);
|
||||
|
||||
Reference in New Issue
Block a user