[openwrt/openwrt] wifi-scripts: iwinfo.uc: cache survey data in iface object

LEDE Commits lede-commits at lists.infradead.org
Thu Jan 22 02:27:33 PST 2026


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/e855f32bddf8c42da2a0045b30729261a352308a

commit e855f32bddf8c42da2a0045b30729261a352308a
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Thu Jan 22 11:25:49 2026 +0100

    wifi-scripts: iwinfo.uc: cache survey data in iface object
    
    Extract survey fetching into get_survey() and store results in iface.survey,
    allowing access to full survey info (not just noise) for later use.
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 .../wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc
index 4bc04134a6..f77ce0b58e 100644
--- a/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc
+++ b/package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc
@@ -21,15 +21,16 @@ function find_phy(wiphy) {
 	return null;
 }
 
-function get_noise(iface) {
-	for (let phy in phys) {
-		let channels = nl80211.request(nl80211.const.NL80211_CMD_GET_SURVEY, nl80211.const.NLM_F_DUMP, { dev: iface.ifname });
-		for (let k, channel in channels)
-			if (channel.survey_info.frequency == iface.wiphy_freq)
-				return channel.survey_info.noise;
-	}
+function get_survey(iface) {
+	let channels = nl80211.request(nl80211.const.NL80211_CMD_GET_SURVEY, nl80211.const.NLM_F_DUMP, { dev: iface.ifname });
+	for (let channel in channels)
+		if (channel.survey_info?.frequency == iface.wiphy_freq)
+			return channel.survey_info;
+	return null;
+}
 
-	return -100;
+function get_noise(iface) {
+	return iface.survey?.noise ?? -100;
 }
 
 function get_country(iface) {
@@ -104,6 +105,7 @@ export function update() {
 		let iface = ifaces[v.ifname] = v;
 
 		iface.mode = iftypes[iface.iftype] ?? 'unknown',
+		iface.survey = get_survey(iface);
 		iface.noise = get_noise(iface);
 		iface.country = get_country(iface);
 		iface.max_power = get_max_power(iface);




More information about the lede-commits mailing list