Fix wifi power offset calculation. (#265)

This commit is contained in:
Tim Wilkinson 2022-03-05 19:50:06 -08:00 committed by GitHub
parent c1ab4f9a51
commit 17d76bed07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -84,6 +84,27 @@ function hardware.wifi_maxpower(channel)
return 27 -- if all else fails
end
function hardware.wifi_poweroffset(wifiintf)
local doesiwoffset = nil
local f = io.popen("iwinfo " .. wifiintf .. " info")
if f then
for line in f:lines()
do
doesiwoffset = tonumber(line:match("TX power offset: (%d+)"))
if doesiwoffset then
f:close()
return doesiwoffset
end
end
f:close()
end
local radio = hardware.get_radio()
if radio and tonumber(radio.pwroffset) then
return tonumber(radio.pwroffset)
end
return 0 -- if all else fails
end
function hardware.get_board_id()
local name = ""
if hardware.get_board().model.name:match("^(%S*)") == "Ubiquiti" then

View File

@ -133,14 +133,6 @@ function rf_channels_list(wifiintf)
return channels
end
function wifi_txpoweroffset(wifiintf)
local doesiwoffset = capture_and_match("iwinfo " .. wifiintf .. " info", "TX power offset: (%d+)")
if doesiwoffset then
return tonumber(doesiwoffset)
end
return 0
end
function reboot()
local node = aredn_info.get_nvram("node")
if node == "" then
@ -1042,7 +1034,7 @@ if wifi_enable == "1" then
html.print("<tr><td colspan=2 align=center><hr><small>Active Settings</small></td></tr>")
html.print("<tr><td><nobr>Tx Power</nobr></td><td><select name=wifi_txpower>")
local txpoweroffset = wifi_txpoweroffset(wifiintf)
local txpoweroffset = aredn.hardware.wifi_poweroffset(wifiintf)
for i = aredn.hardware.wifi_maxpower(wifi_channel),1,-1
do
html.print("<option value='" .. i .. "'".. (i == tonumber(wifi_txpower) and " selected" or "") .. ">" .. (txpoweroffset + i) .. " dBm</option>")