From 963bcfd3ee22873cbd2d66b49f23cc43ae2f4432 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Sat, 19 Jun 2021 17:57:21 +0200 Subject: [PATCH] site: disallow usage of outdoor mode in case outdoor_chanlist is missing The documentation states the outdoor mode is only enabled in case outdoor_chanlist is defined in the sites wifi5 configurationsection: > If enabled, by setting ``wifi5.outdoor_chanlist``, a number of > devices that are commonly installed outdoors will have outdoor > mode automatically enabled during their initial setup This currently does not hold true, as Outdoor mode is always activated for these devices on first setup, even in case the site does not specify an outdoor chanlist. Furthermore, it also does not make sense to show the option neither in setup-modes basic nor advences configuration view in case the site is lacking an out door chanlist. This patch will disable outdoor mode on new installs in case the outdoor chanlist is missing. It will also not show the respective configuration options in this case. Signed-off-by: David Bauer --- .../luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua | 5 +++++ package/gluon-core/check_site.lua | 6 ++++-- package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors | 6 +++++- package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua | 4 ++++ .../lib/gluon/config-mode/model/admin/wifi-config.lua | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) 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 2fbc0fba..56211f9f 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 @@ -12,6 +12,11 @@ return function(form, uci) return end + if not wireless.site_supports_outdoor_mode() then + -- Don't show in case the site does not support outdoor-mode + return + end + local pkg_i18n = i18n 'gluon-config-mode-outdoor' local section = form:section(Section, nil, pkg_i18n.translate( diff --git a/package/gluon-core/check_site.lua b/package/gluon-core/check_site.lua index 3966592d..9f0140cd 100644 --- a/package/gluon-core/check_site.lua +++ b/package/gluon-core/check_site.lua @@ -44,8 +44,10 @@ for _, config in ipairs({'wifi24', 'wifi5'}) do 120, 122, 124, 126, 128, 132, 134, 136, 138, 140, 142, 144, 149, 151, 153, 155, 157, 159, 161, 165, 169, 173 } need_one_of({config, 'channel'}, channels) - need_chanlist({config, 'outdoor_chanlist'}, channels, false) - need_one_of({config, 'outdoors'}, {true, false, 'preset'}, false) + + local outdoors = need_one_of({config, 'outdoors'}, {true, false, 'preset'}, false) + local outdoor_chanlist_required = (outdoors ~= false) + need_chanlist({config, 'outdoor_chanlist'}, channels, outdoor_chanlist_required) end obsolete({config, 'supported_rates'}, '802.11b rates are disabled by default.') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors b/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors index 5c5a92e2..a55e8581 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors @@ -13,11 +13,15 @@ end local sysconfig = require 'gluon.sysconfig' local platform = require 'gluon.platform' +local wireless = require 'gluon.wireless' local config = site.wifi5.outdoors('preset') local outdoor -if sysconfig.gluon_version then +if not wireless.site_supports_outdoor_mode() then + -- site does not support outdoor mode + outdoor = false +elseif sysconfig.gluon_version then -- don't enable the outdoor mode after an upgrade outdoor = false elseif config == 'preset' then diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua index 4f2cf088..8dfce5e1 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua @@ -100,4 +100,8 @@ function M.preserve_channels(uci) return uci:get_first('gluon-core', 'wireless', 'preserve_channels') end +function M.site_supports_outdoor_mode() + return site.wifi5.outdoor_chanlist() ~= nil +end + return M 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 49580413..ed2059dd 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 @@ -142,7 +142,7 @@ uci:foreach('wireless', 'wifi-device', function(config) end) -if has_5ghz_radio() and not wireless.preserve_channels(uci) then +if has_5ghz_radio() and not wireless.preserve_channels(uci) and wireless.site_supports_outdoor_mode() then local r = f:section(Section, translate("Outdoor Installation"), translate( "Configuring the node for outdoor use tunes the 5 GHz radio to a frequency " .. "and transmission power that conforms with the local regulatory requirements. "