[openwrt/openwrt] wifi-scripts: populate default wifi credentials and country code from board.json
LEDE Commits
lede-commits at lists.infradead.org
Wed Oct 2 06:48:13 PDT 2024
blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b506a305fea85cbf1a822dfeb54d5a65906b31df
commit b506a305fea85cbf1a822dfeb54d5a65906b31df
Author: John Crispin <john at phrozen.org>
AuthorDate: Tue Sep 17 15:10:20 2024 +0200
wifi-scripts: populate default wifi credentials and country code from board.json
Signed-off-by: John Crispin <john at phrozen.org>
---
.../config/wifi-scripts/files/lib/wifi/mac80211.uc | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc
index b68167b754..9fd6c35e8b 100644
--- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc
+++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc
@@ -71,20 +71,34 @@ for (let phy_name, phy in board.wlan) {
if (match(phy_name, /^phy[0-9]/))
id = `path='${phy.path}'`;
+ band_name = lc(band_name);
+
+ let country, defaults, num_global_macaddr;
+ if (board.wlan.defaults) {
+ defaults = board.wlan.defaults.ssids?.[band_name]?.ssid ? board.wlan.defaults.ssids?.[band_name] : board.wlan.defaults.ssids?.all;
+ country = board.wlan.defaults.country;
+ if (!country && band_name != '2g')
+ defaults = null;
+ num_global_macaddr = board.wlan.defaults.ssids?.[band_name]?.mac_count;
+ }
+
print(`set ${s}=wifi-device
set ${s}.type='mac80211'
set ${s}.${id}
-set ${s}.band='${lc(band_name)}'
+set ${s}.band='${band_name}'
set ${s}.channel='${channel}'
set ${s}.htmode='${htmode}'
-set ${s}.disabled='1'
+set ${s}.country='${country || ''}'
+set ${s}.num_global_macaddr='${num_global_macaddr || ''}'
+set ${s}.disabled='${defaults ? 0 : 1}'
set ${si}=wifi-iface
set ${si}.device='${name}'
set ${si}.network='lan'
set ${si}.mode='ap'
-set ${si}.ssid='OpenWrt'
-set ${si}.encryption='none'
+set ${si}.ssid='${defaults?.ssid || "OpenWrt"}'
+set ${si}.encryption='${defaults?.encryption || "none"}'
+set ${si}.key='${defaults?.key || ""}'
`);
commit = true;
More information about the lede-commits
mailing list