Skip to content

Commit

Permalink
gluon-core: lua: wireless: add support for PHYs named in board.json
Browse files Browse the repository at this point in the history
On mediatek-mt7622, board.json contains a PHY -> path mapping (which
confusingly also uses the `phy` UCI option). Look up the mapping and pass
the path query into iwinfo, like OpenWrt's mac80211.sh does.
  • Loading branch information
neocturne committed Jan 27, 2025
1 parent ff58f65 commit f85b20d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 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 @@ -5,10 +5,28 @@ local util = require 'gluon.util'
local unistd = require 'posix.unistd'

local iwinfo = require 'iwinfo'
local json = require 'jsonc'

local M = {}

local wlan_data

function M.find_phy(config)
-- Avoid loading board.json if config.phy isn't set
if config.phy then
if not wlan_data then
local board_data = json.load('/etc/board.json')
wlan_data = board_data.wlan or {}
end

local path = (wlan_data[config.phy] or {}).path
if path then
-- Currently only used on mediatek-mt7622. On all other targets,
-- wlan_data will not have any PHY entries, so path will be nil.
return iwinfo.nl80211.phyname('path=' .. path)
end
end

return iwinfo.nl80211.phyname(config['.name'])
end

Expand Down

0 comments on commit f85b20d

Please sign in to comment.