Skip to content

Commit

Permalink
fixup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Oct 13, 2024
1 parent 45a0ee4 commit b827984
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local wireless = require 'gluon.wireless'

local uci = require('simple-uci').cursor()
local sysconfig = require 'gluon.sysconfig'
local iwinfo = require 'iwinfo'


local function is_disabled(config, name)
Expand All @@ -24,7 +23,7 @@ local function configure_ap(radio, index, config, radio_name)
local ap = config.ap
local disabled = is_disabled(ap, name)

if not util.supports_channel(radio, config.channel()) then
if not wireless.supports_channel(radio, config.channel()) then
has_client_radio = true
end

Expand Down Expand Up @@ -121,12 +120,12 @@ wireless.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)
wireless.foreach_radio(uci, function(radio, _, 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
if wireless.supports_channel(radio, config.channel()) and (radio.hwmode == '11a' or radio.hwmode == '11na') then
uci:set('wireless', name, 'disabled', true)
end
end)
Expand Down
4 changes: 2 additions & 2 deletions package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local function is_outdoor()
end

local function get_channel(radio, config)
if radio.band == '5g' and (is_outdoor() or not util.supports_channel(radio, config.channel())) then
if radio.band == '5g' and (is_outdoor() or not wireless.supports_channel(radio, config.channel())) then
-- actual channel will be picked and probed from chanlist
return 'auto'
end
Expand Down Expand Up @@ -227,7 +227,7 @@ wireless.foreach_radio(uci, function(radio, index, config)
util.remove_from_set(hostapd_options, 'country3=0x4f')
uci:set_list('wireless', radio_name, 'hostapd_options', hostapd_options)

if is_outdoor() or not util.supports_channel(radio, config.channel()) then
if is_outdoor() or not wireless.supports_channel(radio, config.channel()) then
-- enforce outdoor channels by filtering the regdom for outdoor channels
uci:set('wireless', radio_name, 'country3', '0x4f')
configure_mesh_wireless(radio, index, config, true)
Expand Down
10 changes: 0 additions & 10 deletions package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,6 @@ function M.get_role_interfaces(uci, role, exclusive)
return ret
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

-- Safe glob: returns an empty table when the glob fails because of
-- a non-existing path
function M.glob(pattern)
Expand Down
10 changes: 10 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 @@ -92,6 +92,16 @@ local function get_wlan_mac_from_driver(radio, vif)
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

function M.get_wlan_mac(_, radio, index, vif)
local addr = get_wlan_mac_from_driver(radio, vif)
if addr then
Expand Down

0 comments on commit b827984

Please sign in to comment.