mirror of https://github.com/aredn/aredn.git
More multi-radio support (#860)
* Multi-radio: Support different powers for different radios * Use arrays for powers * Update APIs to take wifi interface
This commit is contained in:
parent
225773cf06
commit
60a2627989
|
@ -225,10 +225,10 @@
|
|||
"maxpower" : "25"
|
||||
},
|
||||
"MikroTik hAP ac2" : {
|
||||
"maxpower" : "27"
|
||||
"maxpower" : [ "27", "26" ]
|
||||
},
|
||||
"MikroTik hAP ac3" : {
|
||||
"maxpower" : "27"
|
||||
"maxpower" : [ "26", "26" ]
|
||||
},
|
||||
"0xe005" : {
|
||||
"name" : "Ubiquiti NanoStation M5",
|
||||
|
@ -470,8 +470,8 @@
|
|||
},
|
||||
"0xe7fc": {
|
||||
"name" : "Ubiquiti NanoBeam AC Gen2 (WA)",
|
||||
"maxpower" : "25",
|
||||
"pwroffset" : "2"
|
||||
"maxpower" : [ "25", "20" ],
|
||||
"pwroffset" : [ "2", "0" ]
|
||||
},
|
||||
"0xe7f9": {
|
||||
"name" : "Ubiquiti LiteBeam 5AC Gen2",
|
||||
|
|
|
@ -83,8 +83,8 @@ function module:GET()
|
|||
data.meshrf.distance = aredn_info.getMeshRadioDistance(radio)
|
||||
data.meshrf.bw = aredn_info.getChannelBW(radio)
|
||||
data.meshrf.channel = aredn_info.getChannel(radio)
|
||||
data.meshrf.power = aredn_info.getTXPower()
|
||||
data.meshrf.maxpower = aredn_hardware.wifi_maxpower(data['meshrf']['channel'])
|
||||
data.meshrf.power = aredn_info.getTXPower(radio)
|
||||
data.meshrf.maxpower = aredn_hardware.wifi_maxpower(radio, data['meshrf']['channel'])
|
||||
|
||||
|
||||
-- LAN
|
||||
|
|
|
@ -70,21 +70,31 @@ function hardware.get_radio()
|
|||
return radio_json
|
||||
end
|
||||
|
||||
function hardware.wifi_maxpower(channel)
|
||||
function hardware.wifi_maxpower(wifiintf, channel)
|
||||
local radio = hardware.get_radio()
|
||||
if radio then
|
||||
if radio.chanpower then
|
||||
for k, v in pairs(radio.chanpower)
|
||||
local maxpower = radio.maxpower
|
||||
local chanpower = radio.chanpower
|
||||
if chanpower then
|
||||
if type(maxpower) == "table" then
|
||||
chanpower = chanpower[1 + tonumber(wifiintf:match("(%d+)$"))]
|
||||
end
|
||||
for k, v in pairs(chanpower)
|
||||
do
|
||||
if channel <= tonumber(k) then
|
||||
return tonumber(v)
|
||||
end
|
||||
end
|
||||
elseif radio.maxpower then
|
||||
return tonumber(radio.maxpower)
|
||||
end
|
||||
if type(maxpower) == "table" then
|
||||
maxpower = maxpower[1 + tonumber(wifiintf:match("(%d+)$"))]
|
||||
end
|
||||
maxpower = tonumber(maxpower)
|
||||
if maxpower then
|
||||
return maxpower
|
||||
end
|
||||
end
|
||||
return 27 -- if all else fails
|
||||
return 27 -- default
|
||||
end
|
||||
|
||||
function hardware.wifi_poweroffset(wifiintf)
|
||||
|
@ -102,10 +112,17 @@ function hardware.wifi_poweroffset(wifiintf)
|
|||
f:close()
|
||||
end
|
||||
local radio = hardware.get_radio()
|
||||
if radio and tonumber(radio.pwroffset) then
|
||||
return tonumber(radio.pwroffset)
|
||||
if radio then
|
||||
local pwroffset = radio.pwroffset
|
||||
if type(pwroffset) == "table" then
|
||||
pwroffset = pwroffset[1 + tonumber(wifiintf:match("(%d+)$"))]
|
||||
end
|
||||
pwroffset = tonumber(pwroffset)
|
||||
if pwroffset then
|
||||
return pwroffset
|
||||
end
|
||||
end
|
||||
return 0 -- if all else fails
|
||||
return 0 -- default
|
||||
end
|
||||
|
||||
function hardware.get_board_id()
|
||||
|
|
|
@ -256,8 +256,7 @@ end
|
|||
-------------------------------------
|
||||
-- Return TX Power
|
||||
-------------------------------------
|
||||
function model.getTXPower()
|
||||
local wlanInf=get_ifname('wifi')
|
||||
function model.getTXPower(wlanInf)
|
||||
local api=iwinfo.type(wlanInf)
|
||||
local iw = iwinfo[api]
|
||||
local power = iw.txpower(wlanInf)
|
||||
|
@ -267,8 +266,7 @@ end
|
|||
-------------------------------------
|
||||
-- Return Frequency
|
||||
-------------------------------------
|
||||
function model.getFreq()
|
||||
local wlanInf=get_ifname('wifi')
|
||||
function model.getFreq(wlanInf)
|
||||
local api=iwinfo.type(wlanInf)
|
||||
local iw = iwinfo[api]
|
||||
local freq = iw.frequency(wlanInf)
|
||||
|
|
|
@ -650,8 +650,8 @@ if sf then
|
|||
sf:write("#!/bin/sh\n")
|
||||
if cfg.wifi_proto ~= "disabled" then
|
||||
local wifi_channel = tonumber(cfg.wifi_channel)
|
||||
if is_null(cfg.wifi_txpower) or tonumber(cfg.wifi_txpower) > aredn.hardware.wifi_maxpower(wifi_channel) then
|
||||
cfg.wifi_txpower = aredn.hardware.wifi_maxpower(wifi_channel)
|
||||
if is_null(cfg.wifi_txpower) or tonumber(cfg.wifi_txpower) > aredn.hardware.wifi_maxpower(cfg.wifi_intf, wifi_channel) then
|
||||
cfg.wifi_txpower = aredn.hardware.wifi_maxpower(cfg.wifi_intf, wifi_channel)
|
||||
elseif tonumber(cfg.wifi_txpower) < 1 then
|
||||
cfg.wifi_txpower = 1
|
||||
end
|
||||
|
|
|
@ -170,7 +170,7 @@ if loops == 0 then
|
|||
end
|
||||
|
||||
local myssid = aredn.info.getSSID()
|
||||
local myfreq = tonumber(aredn.info.getFreq())
|
||||
local myfreq = tonumber(aredn.info.getFreq(iface))
|
||||
|
||||
for _ = 1,loops
|
||||
do
|
||||
|
|
|
@ -111,7 +111,7 @@ local f = io.popen("iw dev " .. wifiiface .. " station dump")
|
|||
if f then
|
||||
local scan = {}
|
||||
local myssid = aredn_info.getSSID()
|
||||
local myfreq = tonumber(aredn_info.getFreq())
|
||||
local myfreq = tonumber(aredn_info.getFreq(wifiiface))
|
||||
for line in f:lines()
|
||||
do
|
||||
local m = line:match("^Station ([%da-fA-F:]+) %(on " .. wifiiface .. "%)")
|
||||
|
|
|
@ -362,8 +362,8 @@ if cursor:get("aredn", "@lqm[0]", "enable") == "1" then
|
|||
end
|
||||
|
||||
-- sanitize the active settings
|
||||
if not wifi_txpower or wifi_txpower > aredn.hardware.wifi_maxpower(wifi_channel) then
|
||||
wifi_txpower = aredn.hardware.wifi_maxpower(wifi_channel)
|
||||
if not wifi_txpower or wifi_txpower > aredn.hardware.wifi_maxpower(wifi_intf, wifi_channel) then
|
||||
wifi_txpower = aredn.hardware.wifi_maxpower(wifi_intf, wifi_channel)
|
||||
end
|
||||
if not wifi_power or wifi_power < 1 then
|
||||
wifi_power = 1
|
||||
|
@ -1113,7 +1113,7 @@ if wifi_enable == "1" then
|
|||
end
|
||||
html.print("<tr><td><nobr>Tx Power</nobr></td><td><select name=wifi_txpower>")
|
||||
local txpoweroffset = aredn.hardware.wifi_poweroffset(wifi_intf)
|
||||
for i = aredn.hardware.wifi_maxpower(wifi_channel),1,-1
|
||||
for i = aredn.hardware.wifi_maxpower(wifi_intf, wifi_channel),1,-1
|
||||
do
|
||||
html.print("<option value='" .. i .. "'".. (i == tonumber(wifi_txpower) and " selected" or "") .. ">" .. (txpoweroffset + i) .. " dBm</option>")
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ if ( radio ~= nil and radio ~= "" ) then
|
|||
info['meshrf']['ssid']=aredn_info.getSSID()
|
||||
info['meshrf']['channel']=aredn_info.getChannel(radio)
|
||||
info['meshrf']['chanbw']=aredn_info.getChannelBW(radio)
|
||||
info['meshrf']['freq']=aredn_info.getFreq()
|
||||
info['meshrf']['freq']=aredn_info.getFreq(radio)
|
||||
else
|
||||
info['meshrf']['status']="off"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue