Merge pull request #2049 from freifunk-gluon/outdoor-mode-commit

Fix /etc/config/network commit for outdoor mode change, and related fixes
This commit is contained in:
David Bauer 2020-06-07 03:09:00 +02:00 committed by GitHub
commit 5d51b7dc2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 9 deletions

View File

@ -25,5 +25,5 @@ return function(form, uci)
end
end
return {'gluon', 'wireless'}
return {'gluon', 'network', 'wireless'}
end

View File

@ -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')

View File

@ -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
@ -71,14 +76,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,17 +93,23 @@ 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
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
@ -143,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
@ -181,6 +195,7 @@ end
function f:write()
uci:commit('gluon')
os.execute('/lib/gluon/upgrade/200-wireless')
uci:commit('network')
uci:commit('wireless')
end