From 9720be51126235b3312b0bc2255a36d5d4feb20d Mon Sep 17 00:00:00 2001 From: David Bauer Date: Mon, 2 Mar 2020 23:59:18 +0100 Subject: [PATCH] gluon-web-wifi-config: set state of OWE VAP --- .../config-mode/model/admin/wifi-config.lua | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 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 e1971de7..58145527 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 @@ -61,21 +61,45 @@ uci:foreach('wireless', 'wifi-device', function(config) local p = f:section(Section, title) - local function vif_option(t, msg) - if not uci:get('wireless', t .. '_' .. radio) then + local function filter_existing_interfaces(interfaces) + local out = {} + for _, interface in ipairs(interfaces) do + if uci:get('wireless', interface .. '_' .. radio) then + table.insert(out, interface) + end + end + return out + end + + local function filter_active_interfaces(interfaces) + local out = false + for _, interface in ipairs(interfaces) do + if not uci:get_bool('wireless', interface .. '_' .. radio, 'disabled') then + out = true + end + end + return out + end + + local function vif_option(name, interfaces, msg) + local existing_interfaces = filter_existing_interfaces(interfaces) + + if #existing_interfaces == 0 then return end - local o = p:option(Flag, radio .. '_' .. t .. '_enabled', msg) - o.default = not uci:get_bool('wireless', t .. '_' .. radio, 'disabled') + local o = p:option(Flag, radio .. '_' .. name .. '_enabled', msg) + o.default = filter_active_interfaces(existing_interfaces) function o:write(data) - uci:set('wireless', t .. '_' .. radio, 'disabled', not data) + for _, interface in ipairs(existing_interfaces) do + uci:set('wireless', interface .. '_' .. radio, 'disabled', not data) + end end end - vif_option('client', translate('Enable client network (access point)')) - vif_option('mesh', translate("Enable mesh network (802.11s)")) + vif_option('client', {'client', 'owe'}, translate('Enable client network (access point)')) + vif_option('mesh', {'mesh'}, translate("Enable mesh network (802.11s)")) local phy = util.find_phy(config) if not phy then