Api use libiwinfo frequency (#112)

This commit is contained in:
dman776 2021-05-26 09:57:47 -05:00 committed by GitHub
parent 10ff6f512f
commit 79aa11db40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 11 deletions

View File

@ -37,7 +37,7 @@
require("uci") require("uci")
local aredn_uci = require("aredn.uci") local aredn_uci = require("aredn.uci")
require("aredn.utils") require("aredn.utils")
local olsr=require("aredn.olsr")
-- require("aredn.http") -- require("aredn.http")
local lip=require("luci.ip") local lip=require("luci.ip")
require("nixio") require("nixio")
@ -283,11 +283,22 @@ function model.all_services()
hfile:close() hfile:close()
for pos,val in pairs(lines) do for pos,val in pairs(lines) do
local service={} local service={}
local link,protocol,name = string.match(val,"^([^|]*)|(.+)|([^\t]*)\t#.*") local link,protocol,name,ip = string.match(val,"^([^|]*)|(.+)|([^\t]*)\t#(.*)")
if link and protocol and name then if link and protocol and name then
service['link']=link service['link']=link
service['protocol']=protocol service['protocol']=protocol
service['name']=name service['name']=name
if ip==" my own service" then
service['ip']=model.getInterfaceIPAddress("wifi")
else
service['ip']=ip
end
-- MAYBE: convert this to a table lookup from reading /var/run/hosts_olsr to improve performance
hostname=nslookup(service['ip'])
if hostname ~= nil then
hostname = string.gsub(hostname,".local.mesh$","") -- strip .local.mesh
end
service['hostname']=hostname
table.insert(services,service) table.insert(services,service)
end end
end end

View File

@ -34,7 +34,8 @@
--]] --]]
require("aredn.http") require("aredn.http")
require("aredn.utils")
local ai=require("aredn.info")
------------------------------------- -------------------------------------
-- Public API is attached to table -- Public API is attached to table
------------------------------------- -------------------------------------
@ -81,12 +82,13 @@ function model.getCurrentNeighbors(RFinfo)
else else
info[remip]['hostname']=remip info[remip]['hostname']=remip
end end
-- services
-- info[remip]['services']={}
if info[remip]['linkType'] == "RF" and RFinfo then if info[remip]['linkType'] == "RF" and RFinfo then
-- get additional info for RF link -- get additional info for RF link
require("aredn.utils")
require("iwinfo") require("iwinfo")
local radio = ai.getMeshRadioDevice()
local bandwidth = tonumber(ai.getChannelBW(radio))
local wlan=get_ifname('wifi') local wlan=get_ifname('wifi')
local RFneighbors=iwinfo['nl80211'].assoclist(wlan) local RFneighbors=iwinfo['nl80211'].assoclist(wlan)
local mac2node=mac2host() local mac2node=mac2host()
@ -102,6 +104,7 @@ function model.getCurrentNeighbors(RFinfo)
info[remip]["noise"]=tonumber(stnInfo.noise) info[remip]["noise"]=tonumber(stnInfo.noise)
info[remip]["tx_rate"]=adjust_rate(stnInfo.tx_rate/1000,bandwidth) info[remip]["tx_rate"]=adjust_rate(stnInfo.tx_rate/1000,bandwidth)
info[remip]["rx_rate"]=adjust_rate(stnInfo.rx_rate/1000,bandwidth) info[remip]["rx_rate"]=adjust_rate(stnInfo.rx_rate/1000,bandwidth)
info[remip]["expected_throughput"]=adjust_rate(stnInfo.expected_throughput/1000,bandwidth)
end end
end end
end end

View File

@ -46,11 +46,11 @@ function round2(num, idp)
end end
function adjust_rate(r,b) function adjust_rate(r,b)
local ar=r local ar
if b==5 then if b==5 then
ar=round2(ar/4,1) ar=round2(r/4,1)
elseif b==10 then elseif b==10 then
ar=round2(ar/2,1) ar=round2(r/2,1)
end end
return ar return ar
end end

View File

@ -325,9 +325,11 @@ for page, comps in pairs(qsset) do
elseif comp=="localhosts" then elseif comp=="localhosts" then
info['pages'][page][comp]=aredn_info.getLocalHosts() info['pages'][page][comp]=aredn_info.getLocalHosts()
elseif comp=="remotenodes" then elseif comp=="remotenodes" then
info['pages'][page][comp]={} info['pages'][page][comp]={} -- TODO -------------------------
elseif comp=="currentneighbors" then elseif comp=="currentneighbors" then
info['pages'][page][comp]=aredn_olsr.getCurrentNeighbors() info['pages'][page][comp]=aredn_olsr.getCurrentNeighbors(true)
elseif comp=="services" then
info['pages'][page][comp]=aredn_info.all_services()
elseif comp=="previousneighbors" then elseif comp=="previousneighbors" then
info['pages'][page][comp]={} info['pages'][page][comp]={}
end end