diff --git a/files/etc/config.mesh/_setup.default b/files/etc/config.mesh/_setup.default index 2adbef5b..36443302 100644 --- a/files/etc/config.mesh/_setup.default +++ b/files/etc/config.mesh/_setup.default @@ -1,3 +1,4 @@ +wifi_intf = wifi_proto = static wifi_ip = 10. wifi_mask = 255.0.0.0 diff --git a/files/usr/local/bin/mgr/lqm.lua b/files/usr/local/bin/mgr/lqm.lua index e733fbdf..a715b16f 100755 --- a/files/usr/local/bin/mgr/lqm.lua +++ b/files/usr/local/bin/mgr/lqm.lua @@ -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() diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index 4bc1418e..79cc15a8 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -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 diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index 4d844ef0..018c2bac 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -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("") -if phycount > 0 then +if phycount == 1 then html.print("") else html.print("") @@ -1059,6 +1066,19 @@ if phycount > 0 then html.print(" checked") end html.print(">") + 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("") + end end html.print("") @@ -1066,7 +1086,7 @@ if wifi_enable == "1" then html.print("") hidden[#hidden + 1] = "" html.print("") html.print("") end html.print("
Mesh RF (" .. (M3model and "3GHz" or M9model and "900MHz" or wifi_channel < 36 and "2GHz" or "5GHz") .. ")
Mesh
Band
IP Address
Netmask
SSID-" .. wifi_chanbw .. "-v3
Channel  
Channel Width

Power & Distance
Tx Power