mirror of https://github.com/aredn/aredn.git
Support switching mesh radio on multi-radio devices (#847)
This commit is contained in:
parent
62a19a239e
commit
4e621baf0b
|
@ -1,3 +1,4 @@
|
|||
wifi_intf =
|
||||
wifi_proto = static
|
||||
wifi_ip = 10.<MAC2>
|
||||
wifi_mask = 255.0.0.0
|
||||
|
|
|
@ -204,18 +204,13 @@ f:write('{"trackers":{},"hidden_nodes":[]}')
|
|||
f:close()
|
||||
|
||||
-- Get radio
|
||||
local radioname = "radio0"
|
||||
local radiomode = "none"
|
||||
for i = 0,2
|
||||
do
|
||||
if cursor:get("wireless", "@wifi-iface[" .. i .. "]", "network") == "wifi" then
|
||||
radioname = cursor:get("wireless", "@wifi-iface[" .. i .. "]", "device")
|
||||
radiomode = cursor:get("wireless", "@wifi-iface[" .. i .. "]", "mode")
|
||||
break
|
||||
end
|
||||
local wlan = aredn.hardware.get_iface_name("wifi")
|
||||
local phy = "none"
|
||||
if wlan:match("^wlan(%d+)$") then
|
||||
phy = iwinfo.nl80211.phyname(wlan)
|
||||
radiomode = "adhoc"
|
||||
end
|
||||
local phy = "phy" .. radioname:match("radio(%d+)")
|
||||
local wlan = aredn.hardware.get_board_network_ifname("wifi")
|
||||
|
||||
function lqm()
|
||||
|
||||
|
|
|
@ -170,7 +170,9 @@ do
|
|||
end
|
||||
|
||||
if cfg.wifi_enable == "1" then
|
||||
cfg.wifi_intf = aredn.hardware.get_board_network_ifname("wifi"):match("^(%S+)")
|
||||
if not cfg.wifi_intf or cfg.wifi_intf == "" then
|
||||
cfg.wifi_intf = aredn.hardware.get_board_network_ifname("wifi"):match("^(%S+)")
|
||||
end
|
||||
else
|
||||
cfg.wifi_intf = "br-nomesh"
|
||||
end
|
||||
|
|
|
@ -174,9 +174,8 @@ wan_mask = ""
|
|||
wan_gw = ""
|
||||
passwd1 = ""
|
||||
passwd2 = ""
|
||||
wifi_intf = ""
|
||||
|
||||
local wifiintf = aredn.hardware.get_iface_name("wifi")
|
||||
local phy = iwinfo.nl80211.phyname(wifiintf)
|
||||
local phycount = tonumber(capture("ls -1d /sys/class/ieee80211/* | wc -l"):chomp())
|
||||
local radio_name = (aredn.hardware.get_radio() or {}).name or ""
|
||||
local M9model = radio_name:match("M9")
|
||||
|
@ -278,6 +277,11 @@ else
|
|||
end
|
||||
end
|
||||
|
||||
if not wifi_intf or wifi_intf == "" then
|
||||
wifi_intf = aredn.hardware.get_iface_name("wifi")
|
||||
end
|
||||
local phy = iwinfo.nl80211.phyname(wifi_intf)
|
||||
|
||||
-- make sure everything we need is initialized
|
||||
local d0 = { "lan_dhcp", "olsrd_bridge", "wifi2_enable", "wifi_enable", "wifi3_enable", "dhcp_start", "dhcp_end" }
|
||||
for _, k in ipairs(d0)
|
||||
|
@ -341,8 +345,8 @@ parms.dmz_dhcp_limit = dmz_dhcp_end - dmz_dhcp_start + 1
|
|||
|
||||
-- get the active wifi settings on a fresh page load
|
||||
if not parms.reload then
|
||||
wifi_txpower = capture_and_match("iwinfo " .. wifiintf .. " info", "Tx%-Power: (%d+)")
|
||||
local doesiwoffset = capture_and_match("iwinfo " .. wifiintf .. " info", "TX power offset: (%d+)")
|
||||
wifi_txpower = capture_and_match("iwinfo " .. wifi_intf .. " info", "Tx%-Power: (%d+)")
|
||||
local doesiwoffset = capture_and_match("iwinfo " .. wifi_intf .. " info", "TX power offset: (%d+)")
|
||||
if wifi_txpower then
|
||||
wifi_txpower = tonumber(wifi_txpower)
|
||||
if doesiwoffset then
|
||||
|
@ -421,7 +425,7 @@ if (parms.button_apply or parms.button_save) and wifi_enable == "1" then
|
|||
cursorb:commit("aredn")
|
||||
end
|
||||
end
|
||||
os.execute("iw dev " .. wifiintf .. " set txpower fixed " .. wifi_txpower .. "00 >/dev/null 2>&1")
|
||||
os.execute("iw dev " .. wifi_intf .. " set txpower fixed " .. wifi_txpower .. "00 >/dev/null 2>&1")
|
||||
end
|
||||
|
||||
if parms.button_updatelocation then
|
||||
|
@ -521,12 +525,12 @@ if parms.button_save then
|
|||
err("invalid Mesh RF SSID")
|
||||
end
|
||||
|
||||
if wifiintf:match("^br") then
|
||||
wifiintf = aredn.hardware.get_board_network_ifname("wifi")
|
||||
phy = iwinfo.nl80211.phyname(wifiintf)
|
||||
if wifi_intf:match("^br") then
|
||||
wifi_intf = aredn.hardware.get_board_network_ifname("wifi")
|
||||
phy = iwinfo.nl80211.phyname(wifi_intf)
|
||||
end
|
||||
local valid = false
|
||||
for _, c in ipairs(aredn.hardware.get_rfchannels(wifiintf))
|
||||
for _, c in ipairs(aredn.hardware.get_rfchannels(wifi_intf))
|
||||
do
|
||||
if c.number == wifi_channel then
|
||||
valid = true
|
||||
|
@ -730,6 +734,9 @@ if parms.button_save then
|
|||
-- escape and limit description
|
||||
parms.description_node = parms.description_node:sub(1,210):gsub('"',"""):gsub("'","'"):gsub("<","<"):gsub(">",">")
|
||||
|
||||
-- save the wifi interface
|
||||
parms.wifi_intf = wifi_intf
|
||||
|
||||
-- save_setup
|
||||
local f = io.open("/etc/config.mesh/_setup", "w")
|
||||
if f then
|
||||
|
@ -1037,14 +1044,14 @@ html.print([[
|
|||
|
||||
-- reset wifi channel/bandwidth to default
|
||||
if phycount > 0 and (nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset) then
|
||||
local defaultwifi = aredn.hardware.get_default_channel(wifiintf)
|
||||
local defaultwifi = aredn.hardware.get_default_channel(wifi_intf)
|
||||
wifi_channel = defaultwifi.channel
|
||||
wifi_chanbw = tostring(defaultwifi.bandwidth)
|
||||
end
|
||||
|
||||
-- mesh rf settings
|
||||
html.print("<table width=100% style='border-collapse: collapse;'>")
|
||||
if phycount > 0 then
|
||||
if phycount == 1 then
|
||||
html.print("<tr><th colspan=2>Mesh RF (" .. (M3model and "3GHz" or M9model and "900MHz" or wifi_channel < 36 and "2GHz" or "5GHz") .. ")</th></tr>")
|
||||
else
|
||||
html.print("<tr><th colspan=2>Mesh</th></tr>")
|
||||
|
@ -1059,6 +1066,19 @@ if phycount > 0 then
|
|||
html.print(" checked")
|
||||
end
|
||||
html.print("></td></tr>")
|
||||
if phycount > 1 then
|
||||
local defaultwifi = aredn.hardware.get_default_channel(wifi_intf)
|
||||
local alt_wifi = (not phy or phy == "phy0") and "wlan1" or "wlan0"
|
||||
html.print("<tr><td>Band</td><td><select name=wifi_intf onChange='form.submit()'>")
|
||||
if defaultwifi.channel == 149 then
|
||||
html.print("<option value='" .. alt_wifi .. "'>2GHz</option>")
|
||||
html.print("<option value='" .. wifi_intf .. "' selected>5GHz</option>")
|
||||
else
|
||||
html.print("<option value='" .. wifi_intf .. "' selected>2GHz</option>")
|
||||
html.print("<option value='" .. alt_wifi .. "'>5GHz</option>")
|
||||
end
|
||||
html.print("</select></td></tr>")
|
||||
end
|
||||
end
|
||||
html.print("<tr><td><nobr>IP Address</nobr></td><td><input type=text size=15 name=wifi_ip value='" .. wifi_ip .. "'></td></tr><tr><td>Netmask</td><td><input type=text size=15 name=wifi_mask value='" .. wifi_mask .. "'></td></tr>")
|
||||
|
||||
|
@ -1066,7 +1086,7 @@ if wifi_enable == "1" then
|
|||
html.print("<tr><td>SSID</td><td><input type=text size=15 name=wifi_ssid value='" .. wifi_ssid .. "'>-" .. wifi_chanbw .. "-v3</td></tr>")
|
||||
hidden[#hidden + 1] = "<input type=hidden name=wifi_mode value='" .. wifi_mode .. "'>"
|
||||
html.print("<tr><td>Channel</td><td><select name=wifi_channel>")
|
||||
local rfchannels = aredn.hardware.get_rfchannels(wifiintf)
|
||||
local rfchannels = aredn.hardware.get_rfchannels(wifi_intf)
|
||||
table.sort(rfchannels, function(a, b) return a.number < b.number end)
|
||||
for _, chan in ipairs(rfchannels)
|
||||
do
|
||||
|
@ -1075,7 +1095,7 @@ if wifi_enable == "1" then
|
|||
html.print("</select> <a href='/help.html#channel' target='_blank'><img src='/qmark.png'></a></td></tr>")
|
||||
|
||||
html.print("<tr><td>Channel Width</td><td><select name=wifi_chanbw>")
|
||||
for _, width in ipairs(aredn.hardware.get_rfbandwidths(wifiintf))
|
||||
for _, width in ipairs(aredn.hardware.get_rfbandwidths(wifi_intf))
|
||||
do
|
||||
html.print("<option value='" .. width .. "'".. (wifi_chanbw == tostring(width) and " selected" or "") .. ">" .. width .. " MHz</option>")
|
||||
end
|
||||
|
@ -1089,7 +1109,7 @@ if wifi_enable == "1" then
|
|||
html.print("<tr><th colspan=2 align=center><hr><small>Power & Distance</small></th></tr>")
|
||||
end
|
||||
html.print("<tr><td><nobr>Tx Power</nobr></td><td><select name=wifi_txpower>")
|
||||
local txpoweroffset = aredn.hardware.wifi_poweroffset(wifiintf)
|
||||
local txpoweroffset = aredn.hardware.wifi_poweroffset(wifi_intf)
|
||||
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>")
|
||||
|
|
Loading…
Reference in New Issue