From: John Crispin Date: Tue, 17 Mar 2026 11:25:24 +0000 (+0100) Subject: wifi-scripts: make scan output fields conditional X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b6050fe423675c8d6b25d1c5435d21b52d23d8b;p=thirdparty%2Fopenwrt.git wifi-scripts: make scan output fields conditional Only print VHT/HE/EHT center frequency and channel width fields when they are actually populated. This avoids displaying undefined values for non-6GHz HE results where channel info is derived from VHT/HT Operation IEs. Also fix center_chan_2 format specifier from %s to %d. Signed-off-by: John Crispin --- diff --git a/package/network/config/wifi-scripts/files-ucode/usr/bin/iwinfo b/package/network/config/wifi-scripts/files-ucode/usr/bin/iwinfo index d36268b06e9..8bda0bd15f5 100755 --- a/package/network/config/wifi-scripts/files-ucode/usr/bin/iwinfo +++ b/package/network/config/wifi-scripts/files-ucode/usr/bin/iwinfo @@ -95,23 +95,32 @@ function print_scan(cells) { if (cell.vht) { printf('\t VHT Operation:\n'); - printf('\t\tCenter Frequency 1: %d\n', cell.vht.center_chan_1); - printf('\t\tCenter Frequency 2: %s\n', cell.vht.center_chan_2); - printf('\t\tChannel Width: %s\n', cell.vht.chan_width); + if (cell.vht.center_chan_1) + printf('\t\tCenter Frequency 1: %d\n', cell.vht.center_chan_1); + if (cell.vht.center_chan_2) + printf('\t\tCenter Frequency 2: %d\n', cell.vht.center_chan_2); + if (cell.vht.chan_width) + printf('\t\tChannel Width: %s\n', cell.vht.chan_width); } if (cell.he) { printf('\t HE Operation:\n'); - printf('\t\tCenter Frequency 1: %d\n', cell.he.center_chan_1); - printf('\t\tCenter Frequency 2: %s\n', cell.he.center_chan_2); - printf('\t\tChannel Width: %s\n', cell.he.chan_width); + if (cell.he.center_chan_1) + printf('\t\tCenter Frequency 1: %d\n', cell.he.center_chan_1); + if (cell.he.center_chan_2) + printf('\t\tCenter Frequency 2: %d\n', cell.he.center_chan_2); + if (cell.he.chan_width) + printf('\t\tChannel Width: %s\n', cell.he.chan_width); } if (cell.eht) { printf('\t EHT Operation:\n'); - printf('\t\tCenter Frequency 1: %d\n', cell.eht.center_chan_1); - printf('\t\tCenter Frequency 2: %s\n', cell.eht.center_chan_2); - printf('\t\tChannel Width: %s\n', cell.eht.chan_width); + if (cell.eht.center_chan_1) + printf('\t\tCenter Frequency 1: %d\n', cell.eht.center_chan_1); + if (cell.eht.center_chan_2) + printf('\t\tCenter Frequency 2: %d\n', cell.eht.center_chan_2); + if (cell.eht.chan_width) + printf('\t\tChannel Width: %s\n', cell.eht.chan_width); } printf('\n');