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:
commit
5d51b7dc2a
@ -25,5 +25,5 @@ return function(form, uci)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {'gluon', 'wireless'}
|
return {'gluon', 'network', 'wireless'}
|
||||||
end
|
end
|
||||||
|
@ -162,12 +162,13 @@ local function fixup_wan(radio, index)
|
|||||||
uci:set('wireless', name, 'macaddr', macaddr)
|
uci:set('wireless', name, 'macaddr', macaddr)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function configure_mesh_wireless(radio, index, config)
|
local function configure_mesh_wireless(radio, index, config, disabled)
|
||||||
local radio_name = radio['.name']
|
local radio_name = radio['.name']
|
||||||
local suffix = radio_name:match('^radio(%d+)$')
|
local suffix = radio_name:match('^radio(%d+)$')
|
||||||
|
|
||||||
configure_mesh(config.mesh(), radio, index, suffix,
|
configure_mesh(config.mesh(), radio, index, suffix,
|
||||||
first_non_nil(
|
first_non_nil(
|
||||||
|
disabled,
|
||||||
is_disabled('mesh_' .. radio_name),
|
is_disabled('mesh_' .. radio_name),
|
||||||
config.mesh.disabled(false)
|
config.mesh.disabled(false)
|
||||||
)
|
)
|
||||||
@ -215,7 +216,7 @@ wireless.foreach_radio(uci, function(radio, index, config)
|
|||||||
util.add_to_set(hostapd_options, 'country3=0x4f')
|
util.add_to_set(hostapd_options, 'country3=0x4f')
|
||||||
uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options)
|
uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options)
|
||||||
|
|
||||||
uci:delete('wireless', 'mesh_' .. radio_name)
|
configure_mesh_wireless(radio, index, config, true)
|
||||||
else
|
else
|
||||||
uci:delete('wireless', radio_name, 'channels')
|
uci:delete('wireless', radio_name, 'channels')
|
||||||
|
|
||||||
|
@ -47,13 +47,18 @@ f:section(Section, nil, translate(
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
local mesh_vifs_5ghz = {}
|
||||||
|
|
||||||
|
|
||||||
uci:foreach('wireless', 'wifi-device', function(config)
|
uci:foreach('wireless', 'wifi-device', function(config)
|
||||||
local radio = config['.name']
|
local radio = config['.name']
|
||||||
|
|
||||||
|
local is_5ghz = false
|
||||||
local title
|
local title
|
||||||
if config.hwmode == '11g' or config.hwmode == '11ng' then
|
if config.hwmode == '11g' or config.hwmode == '11ng' then
|
||||||
title = translate("2.4GHz WLAN")
|
title = translate("2.4GHz WLAN")
|
||||||
elseif config.hwmode == '11a' or config.hwmode == '11na' then
|
elseif config.hwmode == '11a' or config.hwmode == '11na' then
|
||||||
|
is_5ghz = true
|
||||||
title = translate("5GHz WLAN")
|
title = translate("5GHz WLAN")
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
@ -71,14 +76,13 @@ uci:foreach('wireless', 'wifi-device', function(config)
|
|||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
local function filter_active_interfaces(interfaces)
|
local function has_active_interfaces(interfaces)
|
||||||
local out = false
|
|
||||||
for _, interface in ipairs(interfaces) do
|
for _, interface in ipairs(interfaces) do
|
||||||
if not uci:get_bool('wireless', interface .. '_' .. radio, 'disabled') then
|
if not uci:get_bool('wireless', interface .. '_' .. radio, 'disabled') then
|
||||||
out = true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return out
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function vif_option(name, interfaces, msg)
|
local function vif_option(name, interfaces, msg)
|
||||||
@ -89,17 +93,23 @@ uci:foreach('wireless', 'wifi-device', function(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local o = p:option(Flag, radio .. '_' .. name .. '_enabled', msg)
|
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)
|
function o:write(data)
|
||||||
for _, interface in ipairs(existing_interfaces) do
|
for _, interface in ipairs(existing_interfaces) do
|
||||||
uci:set('wireless', interface .. '_' .. radio, 'disabled', not data)
|
uci:set('wireless', interface .. '_' .. radio, 'disabled', not data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
vif_option('client', {'client', 'owe'}, translate('Enable client network (access point)'))
|
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)
|
local phy = wireless.find_phy(config)
|
||||||
if not phy then
|
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"))
|
local outdoor = r:option(Flag, 'outdoor', translate("Node will be installed outdoors"))
|
||||||
outdoor.default = uci:get_bool('gluon', 'wireless', 'outdoor')
|
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)
|
function outdoor:write(data)
|
||||||
uci:set('gluon', 'wireless', 'outdoor', data)
|
uci:set('gluon', 'wireless', 'outdoor', data)
|
||||||
end
|
end
|
||||||
@ -181,6 +195,7 @@ end
|
|||||||
function f:write()
|
function f:write()
|
||||||
uci:commit('gluon')
|
uci:commit('gluon')
|
||||||
os.execute('/lib/gluon/upgrade/200-wireless')
|
os.execute('/lib/gluon/upgrade/200-wireless')
|
||||||
|
uci:commit('network')
|
||||||
uci:commit('wireless')
|
uci:commit('wireless')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user