From c52089fcda5e5243b168596c07d60637d21404a2 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Mon, 14 Jun 2021 22:29:07 +0200 Subject: [PATCH] treewide: use radio band option to determine frequency band The 'hwmode' setting has been replaced with 'band' in OpenWrt to add support for newer bands outside of 2.4G and 5G. Adjust Gluon accordingly. [Matthias Schiffer: rebased, extended commit message] --- .../lib/gluon/config-mode/wizard/0250-outdoor.lua | 2 +- .../luasrc/lib/gluon/upgrade/200-wireless | 14 +++++++------- .../luasrc/usr/lib/lua/gluon/wireless.lua | 8 ++++---- .../gluon/config-mode/model/admin/wifi-config.lua | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua index 2ddf0a85..947fa0b4 100644 --- a/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua +++ b/package/gluon-config-mode-outdoor/luasrc/lib/gluon/config-mode/wizard/0250-outdoor.lua @@ -31,7 +31,7 @@ return function(form, uci) if data == false then local mesh_ifaces_5ghz = {} uci:foreach('wireless', 'wifi-device', function(config) - if config.hwmode ~= '11a' and config.hwmode ~= '11na' then + if config.band ~= '5g' then return end diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index b86e006e..b0a5485f 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -38,11 +38,11 @@ if not sysconfig.gluon_version then if radio_band_count["band24"] <= radio_band_count["band5"] then -- Assign radio to 2.4GHz band radio_band_count["band24"] = radio_band_count["band24"] + 1 - uci:set('wireless', radio_name, 'hwmode', '11g') + uci:set('wireless', radio_name, 'band', '2g') else -- Assign radio to 5GHz band radio_band_count["band5"] = radio_band_count["band5"] + 1 - uci:set('wireless', radio_name, 'hwmode', '11a') + uci:set('wireless', radio_name, 'band', '5g') end end end) @@ -57,7 +57,7 @@ local function get_channel(radio, config) if wireless.preserve_channels(uci) then -- preserved channel always wins channel = radio.channel - elseif (radio.hwmode == '11a' or radio.hwmode == '11na') and is_outdoor() then + elseif radio.band == '5g' and is_outdoor() then -- actual channel will be picked and probed from chanlist channel = 'auto' end @@ -66,7 +66,7 @@ local function get_channel(radio, config) end local function get_htmode(radio) - if (radio.hwmode == '11a' or radio.hwmode == '11na') and is_outdoor() then + if radio.band == '5g' and is_outdoor() then local outdoor_htmode = uci:get('gluon', 'wireless', 'outdoor_' .. radio['.name'] .. '_htmode') if outdoor_htmode ~= nil then return outdoor_htmode @@ -207,11 +207,11 @@ wireless.foreach_radio(uci, function(radio, index, config) uci:delete('wireless', radio_name, 'supported_rates') uci:delete('wireless', radio_name, 'basic_rate') - local hwmode = radio.hwmode - if hwmode == '11g' or hwmode == '11ng' then + local band = radio.band + if band == '2g' then uci:set('wireless', radio_name, 'legacy_rates', false) configure_mesh_wireless(radio, index, config) - elseif (hwmode == '11a' or hwmode == '11na') then + elseif (band == '5g') then if is_outdoor() then uci:set('wireless', radio_name, 'channels', config.outdoor_chanlist()) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua index 4a6ca757..3e0696aa 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua @@ -112,11 +112,11 @@ function M.foreach_radio(uci, f) end) for index, radio in ipairs(radios) do - local hwmode = radio.hwmode + local band = radio.band - if hwmode == '11g' or hwmode == '11ng' then + if band == '2g' then f(radio, index, site.wifi24) - elseif hwmode == '11a' or hwmode == '11na' then + elseif band == '5g' then f(radio, index, site.wifi5) end end @@ -165,7 +165,7 @@ function M.device_uses_11a(uci) local ret = false uci:foreach('wireless', 'wifi-device', function(radio) - if radio.hwmode == '11a' or radio.hwmode == '11na' then + if radio.band == '5g' then ret = true return false end diff --git a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua index 9915a40b..13ac6434 100644 --- a/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua +++ b/package/gluon-web-wifi-config/luasrc/lib/gluon/config-mode/model/admin/wifi-config.lua @@ -44,9 +44,9 @@ uci:foreach('wireless', 'wifi-device', function(config) local is_5ghz = false local title - if config.hwmode == '11g' or config.hwmode == '11ng' then + if config.band == '2g' then title = translate("2.4GHz WLAN") - elseif config.hwmode == '11a' or config.hwmode == '11na' then + elseif config.band == '5g' then is_5ghz = true title = translate("5GHz WLAN") else @@ -155,9 +155,9 @@ if wireless.device_uses_11a(uci) and not wireless.preserve_channels(uci) then uci:foreach('wireless', 'wifi-device', function(config) local radio = config['.name'] - local hwmode = uci:get('wireless', radio, 'hwmode') + local band = uci:get('wireless', radio, 'band') - if hwmode ~= '11a' and hwmode ~= '11na' then + if band ~= '5g' then return end