gluon-core: deactivate client radios in case a dedicated client radio is present

This commit is contained in:
David Bauer 2019-03-08 16:24:21 +01:00
parent 4e6cad050c
commit 93afbfc747
3 changed files with 33 additions and 3 deletions

View File

@ -3,6 +3,8 @@
local util = require 'gluon.util'
local uci = require('simple-uci').cursor()
local sysconfig = require 'gluon.sysconfig'
local iwinfo = require 'iwinfo'
local function is_disabled(config, name)
@ -13,6 +15,8 @@ local function is_disabled(config, name)
return config.disabled(false)
end
local has_client_radio = false
util.foreach_radio(uci, function(radio, index, config)
local radio_name = radio['.name']
@ -22,6 +26,10 @@ util.foreach_radio(uci, function(radio, index, config)
local ap = config.ap
local disabled = is_disabled(ap, name)
if not util.supports_channel(radio, config.channel()) then
has_client_radio = true
end
uci:delete('wireless', name)
if not ap() then
@ -44,4 +52,16 @@ util.foreach_radio(uci, function(radio, index, config)
})
end)
if not sysconfig.gluon_version and has_client_radio then
util.foreach_radio(uci, function(radio, index, config)
local radio_name = radio['.name']
local name = 'client_' .. radio_name
if util.supports_channel(radio, config.channel()) and (radio.hwmode == '11a' or radio.hwmode == '11na') then
uci:set('wireless', name, 'disabled', true)
end
end)
end
uci:save('wireless')

View File

@ -56,7 +56,8 @@ local function get_channel(radio, config)
if uci:get_first('gluon-core', 'wireless', 'preserve_channels') then
-- preserved channel always wins
channel = radio.channel
elseif (radio.hwmode == '11a' or radio.hwmode == '11na') and is_outdoor() then
elseif (radio.hwmode == '11a' or radio.hwmode == '11na') and (is_outdoor() or not util.supports_channel(radio, config.channel())) then
-- actual channel will be picked and probed from chanlist
channel = 'auto'
end
@ -251,7 +252,7 @@ util.foreach_radio(uci, function(radio, index, config)
uci:set('wireless', radio_name, 'legacy_rates', false)
configure_mesh_wireless(radio, index, config)
elseif (hwmode == '11a' or hwmode == '11na') then
if is_outdoor() then
if is_outdoor() or not util.supports_channel(radio, config.channel()) then
uci:set('wireless', radio_name, 'channels', config.outdoor_chanlist())
-- enforce outdoor channels by filtering the regdom for outdoor channels
@ -275,7 +276,6 @@ util.foreach_radio(uci, function(radio, index, config)
fixup_wan(radio, index)
end)
if uci:get('system', 'rssid_wlan0') then
if uci:get('wireless', 'mesh_radio0') then
uci:set('system', 'rssid_wlan0', 'dev', 'mesh0')

View File

@ -157,6 +157,16 @@ function M.find_phy(config)
end
end
local function supports_channel(radio, channel)
local phy = M.find_phy(radio)
for i, chan in ipairs(iwinfo.nl80211.freqlist(phy)) do
if channel == chan.channel then
return true
end
end
return false
end
local function get_addresses(radio)
local phy = M.find_phy(radio)
if not phy then