]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wifi-scripts: make scan output fields conditional
authorJohn Crispin <john@phrozen.org>
Tue, 17 Mar 2026 11:25:24 +0000 (12:25 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 24 Jun 2026 09:21:28 +0000 (11:21 +0200)
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 <john@phrozen.org>
package/network/config/wifi-scripts/files-ucode/usr/bin/iwinfo

index d36268b06e96c9c6a4e08957d65260742facb97a..8bda0bd15f5f6e7f145f0b92d54ac3831aeb419b 100755 (executable)
@@ -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');