Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

site: disallow usage of outdoor mode in case outdoor_chanlist is missing #2246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions package/gluon-core/check_site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,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.')
Expand Down
5 changes: 4 additions & 1 deletion package/gluon-core/luasrc/lib/gluon/upgrade/180-outdoors
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ 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
Expand Down
4 changes: 4 additions & 0 deletions package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,8 @@ function M.device_uses_11a(uci)
return ret
end

function M.site_supports_outdoor_mode()
return site.wifi5.outdoor_chanlist() ~= nil
end

return M
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,34 @@ uci:foreach('wireless', 'wifi-device', function(config)
end
end)

local function show_outdoor_mode()
local enabled = uci:get_bool('gluon', 'wireless', 'outdoor')

if wireless.device_uses_11a(uci) and not wireless.preserve_channels(uci) then
-- Don't show if no radio is 5 GHz
if not wireless.device_uses_11a(uci) then
return false
end

-- Don't show if preserve_channels is enabled
if wireless.preserve_channels(uci) then
return false
end

-- Show if outdoor mode is enabled regardless if site
-- supports it or not
if not wireless.site_supports_outdoor_mode() then
return true
end

-- Don't show if site does not support outdoor mode
if not wireless.site_supports_outdoor_mode() then
return false
end

return true
end

if show_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. "
Expand Down
Loading