From the command line, wifi status gives lots of detail but it does not tell me which WiFI channel is actually being used when my configuration is set up for automatic channel selection.
wireless.radio0.channel='auto'
Is there a nice clean way to find it, or do I need to parse the output of
iwinfo or iwinfo $dev freqlist ?
Thanks!
efahl
June 12, 2025, 1:55am
2
You can use what LuCI is doing internally and get that same info in nice json output. To see the list of calls,
$ ubus -v list iwinfo
'iwinfo' @d7352a59
"devices":{}
"info":{"device":"String"}
"scan":{"device":"String"}
"assoclist":{"device":"String","mac":"String"}
"freqlist":{"device":"String"}
"txpowerlist":{"device":"String"}
"countrylist":{"device":"String"}
"survey":{"device":"String"}
"phyname":{"section":"String"}
Lets run an interesting looking one
$ ubus call iwinfo devices
{
"devices": [
"phy0-ap0",
"phy1-ap0"
]
}
$ ubus call iwinfo info '{"device":"phy0-ap0"}'
{
"phy": "phy0",
"ssid": "blah",
"bssid": "48:FF:FF:2A:FF:8F",
"country": "US",
"mode": "Master",
"channel": 9,
"center_chan1": 9,
"frequency": 2452,
"frequency_offset": 0,
...
5 Likes
Ah interesting. Very useful
1 Like
efahl
June 12, 2025, 5:19pm
4
Do you know the jsonfilter
tricks for easy use in shell scripts?
$ ubus call iwinfo info '{"device":"phy0-ap0"}' | \
jsonfilter -e 'channel=$.channel' -e 'auth=$.encryption.authentication[*]'
export channel=9; export auth='psk'\ 'sae';
Now just eval the output and you've captured the values in shell variables:
$ eval $(ubus call iwinfo info '{"device":"phy0-ap0"}' | jsonfilter -e 'channel=$.channel' -e 'auth=$.encryption.authentication[*]')
$ echo $channel
9
$ echo $auth
psk sae
5 Likes
Cute eval trick. I like it and it may actually be useful.
efahl
June 12, 2025, 10:24pm
6
But ucode
is much more elegant.
$ cat iwinfo.uc
#!/usr/bin/ucode -S
import * as mod_ubus from "ubus";
let ubus = mod_ubus.connect();
let devices = ubus.call("iwinfo", "devices");
for (let device in devices.devices) {
let info = ubus.call("iwinfo", "info", {device: device});
printf("%s %3d %s\n", device, info.channel, info.bssid);
}
ubus.disconnect();
produces
$ chmod +x iwinfo.uc
$ ./iwinfo.uc
phy0-ap0 9 48:FF:FF:2A:FF:8F
phy1-ap0 40 48:FF:FF:2A:FF:90
2 Likes
@twinkleLED @efahl
I use:
iw dev <ifname> info
For example on a meshnode here I get:
root@meshnode-8ecb:/# iw dev m-11s-0 info
Interface m-11s-0
ifindex 15
wdev 0x3
addr 96:83:c4:a2:8e:cb
type mesh point
wiphy 0
channel 1 (2412 MHz), width: 40 MHz, center1: 2422 MHz
txpower 20.00 dBm
multicast TXQ:
qsz-byt qsz-pkt flows drops marks overlmt hashcol tx-bytes tx-packets
0 0 240396 0 0 0 969 21281035 240410
root@meshnode-8ecb:/#