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_proto = static
|
||||||
wifi_ip = 10.<MAC2>
|
wifi_ip = 10.<MAC2>
|
||||||
wifi_mask = 255.0.0.0
|
wifi_mask = 255.0.0.0
|
||||||
|
|
|
@ -204,18 +204,13 @@ f:write('{"trackers":{},"hidden_nodes":[]}')
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get radio
|
-- Get radio
|
||||||
local radioname = "radio0"
|
|
||||||
local radiomode = "none"
|
local radiomode = "none"
|
||||||
for i = 0,2
|
local wlan = aredn.hardware.get_iface_name("wifi")
|
||||||
do
|
local phy = "none"
|
||||||
if cursor:get("wireless", "@wifi-iface[" .. i .. "]", "network") == "wifi" then
|
if wlan:match("^wlan(%d+)$") then
|
||||||
radioname = cursor:get("wireless", "@wifi-iface[" .. i .. "]", "device")
|
phy = iwinfo.nl80211.phyname(wlan)
|
||||||
radiomode = cursor:get("wireless", "@wifi-iface[" .. i .. "]", "mode")
|
radiomode = "adhoc"
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local phy = "phy" .. radioname:match("radio(%d+)")
|
|
||||||
local wlan = aredn.hardware.get_board_network_ifname("wifi")
|
|
||||||
|
|
||||||
function lqm()
|
function lqm()
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,9 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
if cfg.wifi_enable == "1" then
|
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
|
else
|
||||||
cfg.wifi_intf = "br-nomesh"
|
cfg.wifi_intf = "br-nomesh"
|
||||||
end
|
end
|
||||||
|
|
|
@ -174,9 +174,8 @@ wan_mask = ""
|
||||||
wan_gw = ""
|
wan_gw = ""
|
||||||
passwd1 = ""
|
passwd1 = ""
|
||||||
passwd2 = ""
|
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 phycount = tonumber(capture("ls -1d /sys/class/ieee80211/* | wc -l"):chomp())
|
||||||
local radio_name = (aredn.hardware.get_radio() or {}).name or ""
|
local radio_name = (aredn.hardware.get_radio() or {}).name or ""
|
||||||
local M9model = radio_name:match("M9")
|
local M9model = radio_name:match("M9")
|
||||||
|
@ -278,6 +277,11 @@ else
|
||||||
end
|
end
|
||||||
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
|
-- make sure everything we need is initialized
|
||||||
local d0 = { "lan_dhcp", "olsrd_bridge", "wifi2_enable", "wifi_enable", "wifi3_enable", "dhcp_start", "dhcp_end" }
|
local d0 = { "lan_dhcp", "olsrd_bridge", "wifi2_enable", "wifi_enable", "wifi3_enable", "dhcp_start", "dhcp_end" }
|
||||||
for _, k in ipairs(d0)
|
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
|
-- get the active wifi settings on a fresh page load
|
||||||
if not parms.reload then
|
if not parms.reload then
|
||||||
wifi_txpower = capture_and_match("iwinfo " .. wifiintf .. " info", "Tx%-Power: (%d+)")
|
wifi_txpower = capture_and_match("iwinfo " .. wifi_intf .. " info", "Tx%-Power: (%d+)")
|
||||||
local doesiwoffset = capture_and_match("iwinfo " .. wifiintf .. " info", "TX power offset: (%d+)")
|
local doesiwoffset = capture_and_match("iwinfo " .. wifi_intf .. " info", "TX power offset: (%d+)")
|
||||||
if wifi_txpower then
|
if wifi_txpower then
|
||||||
wifi_txpower = tonumber(wifi_txpower)
|
wifi_txpower = tonumber(wifi_txpower)
|
||||||
if doesiwoffset then
|
if doesiwoffset then
|
||||||
|
@ -421,7 +425,7 @@ if (parms.button_apply or parms.button_save) and wifi_enable == "1" then
|
||||||
cursorb:commit("aredn")
|
cursorb:commit("aredn")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
if parms.button_updatelocation then
|
if parms.button_updatelocation then
|
||||||
|
@ -521,12 +525,12 @@ if parms.button_save then
|
||||||
err("invalid Mesh RF SSID")
|
err("invalid Mesh RF SSID")
|
||||||
end
|
end
|
||||||
|
|
||||||
if wifiintf:match("^br") then
|
if wifi_intf:match("^br") then
|
||||||
wifiintf = aredn.hardware.get_board_network_ifname("wifi")
|
wifi_intf = aredn.hardware.get_board_network_ifname("wifi")
|
||||||
phy = iwinfo.nl80211.phyname(wifiintf)
|
phy = iwinfo.nl80211.phyname(wifi_intf)
|
||||||
end
|
end
|
||||||
local valid = false
|
local valid = false
|
||||||
for _, c in ipairs(aredn.hardware.get_rfchannels(wifiintf))
|
for _, c in ipairs(aredn.hardware.get_rfchannels(wifi_intf))
|
||||||
do
|
do
|
||||||
if c.number == wifi_channel then
|
if c.number == wifi_channel then
|
||||||
valid = true
|
valid = true
|
||||||
|
@ -730,6 +734,9 @@ if parms.button_save then
|
||||||
-- escape and limit description
|
-- escape and limit description
|
||||||
parms.description_node = parms.description_node:sub(1,210):gsub('"',"""):gsub("'","'"):gsub("<","<"):gsub(">",">")
|
parms.description_node = parms.description_node:sub(1,210):gsub('"',"""):gsub("'","'"):gsub("<","<"):gsub(">",">")
|
||||||
|
|
||||||
|
-- save the wifi interface
|
||||||
|
parms.wifi_intf = wifi_intf
|
||||||
|
|
||||||
-- save_setup
|
-- save_setup
|
||||||
local f = io.open("/etc/config.mesh/_setup", "w")
|
local f = io.open("/etc/config.mesh/_setup", "w")
|
||||||
if f then
|
if f then
|
||||||
|
@ -1037,14 +1044,14 @@ html.print([[
|
||||||
|
|
||||||
-- reset wifi channel/bandwidth to default
|
-- reset wifi channel/bandwidth to default
|
||||||
if phycount > 0 and (nixio.fs.stat("/etc/config/unconfigured") or parms.button_reset) then
|
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_channel = defaultwifi.channel
|
||||||
wifi_chanbw = tostring(defaultwifi.bandwidth)
|
wifi_chanbw = tostring(defaultwifi.bandwidth)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- mesh rf settings
|
-- mesh rf settings
|
||||||
html.print("<table width=100% style='border-collapse: collapse;'>")
|
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>")
|
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
|
else
|
||||||
html.print("<tr><th colspan=2>Mesh</th></tr>")
|
html.print("<tr><th colspan=2>Mesh</th></tr>")
|
||||||
|
@ -1059,6 +1066,19 @@ if phycount > 0 then
|
||||||
html.print(" checked")
|
html.print(" checked")
|
||||||
end
|
end
|
||||||
html.print("></td></tr>")
|
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
|
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>")
|
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>")
|
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 .. "'>"
|
hidden[#hidden + 1] = "<input type=hidden name=wifi_mode value='" .. wifi_mode .. "'>"
|
||||||
html.print("<tr><td>Channel</td><td><select name=wifi_channel>")
|
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)
|
table.sort(rfchannels, function(a, b) return a.number < b.number end)
|
||||||
for _, chan in ipairs(rfchannels)
|
for _, chan in ipairs(rfchannels)
|
||||||
do
|
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("</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>")
|
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
|
do
|
||||||
html.print("<option value='" .. width .. "'".. (wifi_chanbw == tostring(width) and " selected" or "") .. ">" .. width .. " MHz</option>")
|
html.print("<option value='" .. width .. "'".. (wifi_chanbw == tostring(width) and " selected" or "") .. ">" .. width .. " MHz</option>")
|
||||||
end
|
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>")
|
html.print("<tr><th colspan=2 align=center><hr><small>Power & Distance</small></th></tr>")
|
||||||
end
|
end
|
||||||
html.print("<tr><td><nobr>Tx Power</nobr></td><td><select name=wifi_txpower>")
|
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
|
for i = aredn.hardware.wifi_maxpower(wifi_channel),1,-1
|
||||||
do
|
do
|
||||||
html.print("<option value='" .. i .. "'".. (i == tonumber(wifi_txpower) and " selected" or "") .. ">" .. (txpoweroffset + i) .. " dBm</option>")
|
html.print("<option value='" .. i .. "'".. (i == tonumber(wifi_txpower) and " selected" or "") .. ">" .. (txpoweroffset + i) .. " dBm</option>")
|
||||||
|
|
Loading…
Reference in New Issue