From 087a182043c2e1adfaf0df714b11bb4cc04b108a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 27 Oct 2026 13:44:45 +0000 Subject: [PATCH] wifi-scripts: detect no radios in mac80211.uc without board.json mac80211.uc parses /etc/board.json with json(readfile()) before it checks for wlan data. Without the file json() rejects the null from readfile(), and the script dies with a type error in "wifi config". Take the wlan data from board_wlan(), which gives none for a missing or empty board.json, so that the script detects no radios and exits 0, as it already does for a board.json without wlan data. Signed-off-by: Felix Fietkau --- .../wifi-scripts/files/lib/wifi/mac80211.uc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 49555fd476f..da5d0975ceb 100644 --- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc +++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc @@ -1,12 +1,13 @@ #!/usr/bin/env ucode import { readfile } from "fs"; import * as uci from 'uci'; +import { board_wlan } from 'wifi.utils'; const bands_order = [ "60G", "6G", "5G", "2G" ]; const htmode_order = [ "EHT", "HE", "VHT", "HT" ]; -let board = json(readfile("/etc/board.json")); -if (!board.wlan) +let wlan = board_wlan(); +if (!wlan) exit(0); function provision_country_get() { @@ -51,7 +52,7 @@ function radio_exists(path, macaddr, phy, radio) { } } -for (let phy_name, phy in board.wlan) { +for (let phy_name, phy in wlan) { let info = phy.info; if (!info || !length(info.bands)) continue; @@ -105,10 +106,10 @@ for (let phy_name, phy in board.wlan) { } else { encryption = 'none'; } - 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; - num_global_macaddr = board.wlan.defaults.ssids?.[band_name]?.mac_count; + if (wlan.defaults) { + defaults = wlan.defaults.ssids?.[band_name]?.ssid ? wlan.defaults.ssids?.[band_name] : wlan.defaults.ssids?.all; + country = wlan.defaults.country; + num_global_macaddr = wlan.defaults.ssids?.[band_name]?.mac_count; } if (provision_country)