Skip to content

Commit 89bc428

Browse files
committed
fix(wireless): Fix undefined behavior when wireless radio is 6g band capable
Falling back on 5g band when the radio is configured by default for 6g band. 6g band is restricted to indoor uses in most places, and require wpa3.
1 parent e82a785 commit 89bc428

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

packages/lime-system/files/usr/lib/lua/lime/wireless.lua

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ function wireless.is5Ghz(radio)
6767
return devModes and (devModes.a or devModes.ac)
6868
end
6969

70+
function wireless.is6Ghz(radio)
71+
local config = require("lime.config")
72+
local uci = config.get_uci_cursor()
73+
wifi_band = uci:get('wireless', radio, 'band')
74+
if wifi_band then return wifi_band=='6g' end
75+
return false
76+
end
77+
78+
function wireless.getRadioBand(radioName)
79+
if wireless.is5Ghz(radioName) then
80+
return '5ghz'
81+
end
82+
if wireless.is6Ghz(radioName) then
83+
--! currently untested and reserved for indoor use
84+
-- let's default to 5ghz for now
85+
-- TODO: test 6g band and decide a path forward with
86+
local uci = config.get_uci_cursor()
87+
uci:set("wireless", radioName, "band", "5g")
88+
return '5ghz'
89+
end
90+
return '2ghz'
91+
end
92+
7093
wireless.availableModes = { adhoc=true, ap=true, apname=true, apbb=true, ieee80211s=true }
7194
function wireless.isMode(m)
7295
return wireless.availableModes[m]
@@ -165,7 +188,7 @@ function wireless.configure()
165188
local allRadios = wireless.scandevices()
166189
for _,radio in pairs(allRadios) do
167190
local radioName = radio[".name"]
168-
local radioBand = wireless.is5Ghz(radioName) and '5ghz' or '2ghz'
191+
local radioBand = wireless.getRadioBand(radioName)
169192
local radioOptions = specificRadios[radioName] or {}
170193
local bandOptions = config.get_all(radioBand) or {}
171194
local options = config.get_all("wifi")

0 commit comments

Comments
 (0)