mirror of https://github.com/aredn/aredn.git
Api use libiwinfo frequency (#112)
This commit is contained in:
parent
10ff6f512f
commit
79aa11db40
|
@ -37,7 +37,7 @@
|
|||
require("uci")
|
||||
local aredn_uci = require("aredn.uci")
|
||||
require("aredn.utils")
|
||||
local olsr=require("aredn.olsr")
|
||||
|
||||
-- require("aredn.http")
|
||||
local lip=require("luci.ip")
|
||||
require("nixio")
|
||||
|
@ -283,11 +283,22 @@ function model.all_services()
|
|||
hfile:close()
|
||||
for pos,val in pairs(lines) do
|
||||
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
|
||||
service['link']=link
|
||||
service['protocol']=protocol
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
|
||||
--]]
|
||||
require("aredn.http")
|
||||
|
||||
require("aredn.utils")
|
||||
local ai=require("aredn.info")
|
||||
-------------------------------------
|
||||
-- Public API is attached to table
|
||||
-------------------------------------
|
||||
|
@ -81,12 +82,13 @@ function model.getCurrentNeighbors(RFinfo)
|
|||
else
|
||||
info[remip]['hostname']=remip
|
||||
end
|
||||
-- services
|
||||
-- info[remip]['services']={}
|
||||
|
||||
if info[remip]['linkType'] == "RF" and RFinfo then
|
||||
-- get additional info for RF link
|
||||
require("aredn.utils")
|
||||
require("iwinfo")
|
||||
|
||||
local radio = ai.getMeshRadioDevice()
|
||||
local bandwidth = tonumber(ai.getChannelBW(radio))
|
||||
local wlan=get_ifname('wifi')
|
||||
local RFneighbors=iwinfo['nl80211'].assoclist(wlan)
|
||||
local mac2node=mac2host()
|
||||
|
@ -102,6 +104,7 @@ function model.getCurrentNeighbors(RFinfo)
|
|||
info[remip]["noise"]=tonumber(stnInfo.noise)
|
||||
info[remip]["tx_rate"]=adjust_rate(stnInfo.tx_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
|
||||
|
|
|
@ -46,11 +46,11 @@ function round2(num, idp)
|
|||
end
|
||||
|
||||
function adjust_rate(r,b)
|
||||
local ar=r
|
||||
local ar
|
||||
if b==5 then
|
||||
ar=round2(ar/4,1)
|
||||
ar=round2(r/4,1)
|
||||
elseif b==10 then
|
||||
ar=round2(ar/2,1)
|
||||
ar=round2(r/2,1)
|
||||
end
|
||||
return ar
|
||||
end
|
||||
|
|
|
@ -325,9 +325,11 @@ for page, comps in pairs(qsset) do
|
|||
elseif comp=="localhosts" then
|
||||
info['pages'][page][comp]=aredn_info.getLocalHosts()
|
||||
elseif comp=="remotenodes" then
|
||||
info['pages'][page][comp]={}
|
||||
info['pages'][page][comp]={} -- TODO -------------------------
|
||||
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
|
||||
info['pages'][page][comp]={}
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue