mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
afc: Use curl instead of uclient to send/receive AFC request/response using hostapd
Fixes: WIFI-14427 Signed-off-by: Tanya Singh <tanya_singh@accton.com>
This commit is contained in:
committed by
John Crispin
parent
1d822a10d2
commit
6d2fd1de0d
@@ -4,19 +4,19 @@ let fs = require("fs");
|
|||||||
let ubus = require('ubus').connect();
|
let ubus = require('ubus').connect();
|
||||||
|
|
||||||
let gps_info = ubus.call('gps', 'info');
|
let gps_info = ubus.call('gps', 'info');
|
||||||
let latitude = gps_info.latitude ?? 0;
|
let latitude = gps_info.latitude || 0;
|
||||||
let longitude = gps_info.longitude ?? 0;
|
let longitude = gps_info.longitude || 0;
|
||||||
|
|
||||||
// afc-location.json file content
|
// afc-location.json file content
|
||||||
let afc_location = {};
|
let afc_location = {};
|
||||||
afc_location.location_type = "ellipse";
|
afc_location.location_type = "ellipse";
|
||||||
afc_location.location = longitude + ":" + latitude ;
|
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.height_type = "AMSL";
|
||||||
afc_location.major_axis = gps_info.major_axis ?? 0;
|
afc_location.major_axis = int(gps_info.major_axis) || 1;
|
||||||
afc_location.minor_axis = gps_info.minor_axis ?? 0;
|
afc_location.minor_axis = int(gps_info.minor_axis) || 1;
|
||||||
afc_location.orientation = gps_info.major_orientation ?? 0;
|
afc_location.orientation = gps_info.major_orientation || 0;
|
||||||
afc_location.vertical_tolerance = gps_info.vdop ?? 0;
|
afc_location.vertical_tolerance = int(gps_info.vdop) || 1;
|
||||||
|
|
||||||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
||||||
afc_location_json.write(afc_location);
|
afc_location_json.write(afc_location);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
let libubus = require("ubus");
|
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";
|
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);
|
let ubus = libubus.connect(null, 60);
|
||||||
|
|
||||||
hostapd.data.config = {};
|
hostapd.data.config = {};
|
||||||
@@ -893,10 +894,21 @@ return {
|
|||||||
hostapd.ubus.disconnect();
|
hostapd.ubus.disconnect();
|
||||||
},
|
},
|
||||||
afc_request: function(iface, data) {
|
afc_request: function(iface, data) {
|
||||||
let ret = ubus.call("afc", "request", { data });
|
let wireless_config = uci.get_all('wireless');
|
||||||
if (type(ret) != "object")
|
for (let l, afc_server in wireless_config) {
|
||||||
return;
|
if (afc_server['.type'] == 'afc-server' && afc_server.url && data) {
|
||||||
return ret.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_add: function(name, obj) {
|
||||||
bss_event("add", name);
|
bss_event("add", name);
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ let fs = require("fs");
|
|||||||
let ubus = require('ubus').connect();
|
let ubus = require('ubus').connect();
|
||||||
|
|
||||||
let gps_info = ubus.call('gps', 'info');
|
let gps_info = ubus.call('gps', 'info');
|
||||||
let latitude = gps_info.latitude ?? 0;
|
let latitude = gps_info.latitude || 0;
|
||||||
let longitude = gps_info.longitude ?? 0;
|
let longitude = gps_info.longitude || 0;
|
||||||
|
|
||||||
// afc-location.json file content
|
// afc-location.json file content
|
||||||
let afc_location = {};
|
let afc_location = {};
|
||||||
afc_location.location_type = "ellipse";
|
afc_location.location_type = "ellipse";
|
||||||
afc_location.location = longitude + ":" + latitude ;
|
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.height_type = "AMSL";
|
||||||
afc_location.major_axis = gps_info.major_axis ?? 0;
|
afc_location.major_axis = int(gps_info.major_axis) || 1;
|
||||||
afc_location.minor_axis = gps_info.minor_axis ?? 0;
|
afc_location.minor_axis = int(gps_info.minor_axis) || 1;
|
||||||
afc_location.orientation = gps_info.major_orientation ?? 0;
|
afc_location.orientation = gps_info.major_orientation || 0;
|
||||||
afc_location.vertical_tolerance = gps_info.vdop ?? 0;
|
afc_location.vertical_tolerance = int(gps_info.vdop) || 1;
|
||||||
|
|
||||||
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
let afc_location_json = fs.open("/etc/ucentral/afc-location.json", "w");
|
||||||
afc_location_json.write(afc_location);
|
afc_location_json.write(afc_location);
|
||||||
|
|||||||
Reference in New Issue
Block a user