From 600ab99f809d78d6281ad999e7e4e4a91322a85c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 6 Jun 2020 15:42:24 +0200 Subject: [PATCH 1/4] gluon-config-mode-outdoor, gluon-web-wifi-config: commit network config 200-wireless will add or remove the mesh network sections of /etc/config/network. Commit this file, so the modified setting doesn't get lost on reboot. Fixes: #2048 --- .../luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua | 2 +- .../luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua index c36c1f8f..3f1f0cbe 100644 --- a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua +++ b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua @@ -25,5 +25,5 @@ return function(form, uci) end end - return {'gluon', 'wireless'} + return {'gluon', 'network', 'wireless'} end diff --git a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua index 32cdc249..ba662d20 100644 --- a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua +++ b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua @@ -181,6 +181,7 @@ end function f:write() uci:commit('gluon') os.execute('/lib/gluon/upgrade/200-wireless') + uci:commit('network') uci:commit('wireless') end From 53c33acaf96e2294fe299511f3db2c9894462395 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 6 Jun 2020 16:48:26 +0200 Subject: [PATCH 2/4] gluon-web-wifi-config: rename and simplify filter_active_interfaces() - Return early - Rename to has_active_interfaces(), as it returns a boolean --- .../lib/gluon/config-mode/model/admin/wifi-config.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua index ba662d20..d8de670a 100644 --- a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua +++ b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua @@ -71,14 +71,13 @@ uci:foreach('wireless', 'wifi-device', function(config) return out end - local function filter_active_interfaces(interfaces) - local out = false + local function has_active_interfaces(interfaces) for _, interface in ipairs(interfaces) do if not uci:get_bool('wireless', interface .. '_' .. radio, 'disabled') then - out = true + return true end end - return out + return false end local function vif_option(name, interfaces, msg) @@ -89,7 +88,7 @@ uci:foreach('wireless', 'wifi-device', function(config) end local o = p:option(Flag, radio .. '_' .. name .. '_enabled', msg) - o.default = filter_active_interfaces(existing_interfaces) + o.default = has_active_interfaces(existing_interfaces) function o:write(data) for _, interface in ipairs(existing_interfaces) do From d012d7d32fa5235fd260efab64142005f8d36c2f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 6 Jun 2020 16:58:00 +0200 Subject: [PATCH 3/4] gluon-web-wifi-config: make mesh VIF options depend on outdoor=false Instead of relying on the existence of interface sections only (which is still used for the case of interface types that are not configured at all in the site config), add a proper dependency. This fixes section visiblity with enabled outdoor mode after the following fix, and gives the user immediate feedback (allowing to disable outdoor mode and enable meshing in a single step). --- .../config-mode/model/admin/wifi-config.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua index d8de670a..98501bd8 100644 --- a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua +++ b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua @@ -47,13 +47,18 @@ f:section(Section, nil, translate( )) +local mesh_vifs_5ghz = {} + + uci:foreach('wireless', 'wifi-device', function(config) local radio = config['.name'] + local is_5ghz = false local title if config.hwmode == '11g' or config.hwmode == '11ng' then title = translate("2.4GHz WLAN") elseif config.hwmode == '11a' or config.hwmode == '11na' then + is_5ghz = true title = translate("5GHz WLAN") else return @@ -95,10 +100,16 @@ uci:foreach('wireless', 'wifi-device', function(config) uci:set('wireless', interface .. '_' .. radio, 'disabled', not data) end end + + return o end vif_option('client', {'client', 'owe'}, translate('Enable client network (access point)')) - vif_option('mesh', {'mesh'}, translate("Enable mesh network (802.11s)")) + + local mesh_vif = vif_option('mesh', {'mesh'}, translate("Enable mesh network (802.11s)")) + if is_5ghz then + table.insert(mesh_vifs_5ghz, mesh_vif) + end local phy = wireless.find_phy(config) if not phy then @@ -142,6 +153,10 @@ if has_5ghz_radio() then local outdoor = r:option(Flag, 'outdoor', translate("Node will be installed outdoors")) outdoor.default = uci:get_bool('gluon', 'wireless', 'outdoor') + for _, mesh_vif in ipairs(mesh_vifs_5ghz) do + mesh_vif:depends(outdoor, false) + end + function outdoor:write(data) uci:set('gluon', 'wireless', 'outdoor', data) end From b15b008e6951084531b69583076931be844fe075 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 6 Jun 2020 16:30:38 +0200 Subject: [PATCH 4/4] gluon-core: create disabled mesh interface sections in outdoor mode The interfaces should always exist and just be disabled when outdoor mode is enabled. Not creating them at all leads to an issue in the advanced wifi settings where an additional reload of the page is necessary after enabling or disabling the ourdoor mode to make the mesh VIF options appear or disappear. --- package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index 5cc43f68..f72908a2 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -162,12 +162,13 @@ local function fixup_wan(radio, index) uci:set('wireless', name, 'macaddr', macaddr) end -local function configure_mesh_wireless(radio, index, config) +local function configure_mesh_wireless(radio, index, config, disabled) local radio_name = radio['.name'] local suffix = radio_name:match('^radio(%d+)$') configure_mesh(config.mesh(), radio, index, suffix, first_non_nil( + disabled, is_disabled('mesh_' .. radio_name), config.mesh.disabled(false) ) @@ -215,7 +216,7 @@ wireless.foreach_radio(uci, function(radio, index, config) util.add_to_set(hostapd_options, 'country3=0x4f') uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options) - uci:delete('wireless', 'mesh_' .. radio_name) + configure_mesh_wireless(radio, index, config, true) else uci:delete('wireless', radio_name, 'channels')