Iw: resource is bussy(-16) always

I need to set a specific Wi-Fi channel using iw-util(it is necessary evade a uci/luci).
I've downloaded basic firmware for my router(Linksys C1900WRT v1.0) from firmware selector and trying to set a specific channel and bandwidth value with this:
root@OpenWrt:~# iw dev phy0-ap0 set channel 11 HT20
And every time I get this error:
command failed: Resource busy (-16)
With searching the Internet I've found out, that for some reason my AP scans networks every 0.1s. My assumption is based on output of this command:
watch -n 0 iw wlan0 scan

The only way I can to execute this iw dev phy0-ap0 set channel 11 HT20 without finding out an error is putting the AP's interface down, but for some reason changes are not getting saved then.
SO how can I set a desirable channel and bandwidth?

P.S.: I think some time ago I did it successfully on some x86_64 OpenWRT machine, but now it doesn't work for some reason or I forgot some steps to do.

I'm pretty sure you have to first have put the interface down then that command then you have to bring it up

ip link set phy0-ap0 down
iw phy0-ap0.......
ip link set phy0-ap0 up

Your probably better off using UCI commands the command you are using is only temporary and be lost on next reboot or restarting the network

I know that UCI is better due to it saves state, but at my case I need to use some other way to setup a channel.

And here's the thing that I can't get, there's nothing changing for some reason:

root@OpenWrt:~# ip l set dev phy0-ap0 down
root@OpenWrt:~# iw dev phy0-ap0 set channel 1
root@OpenWrt:~# ip l set dev phy0-ap0 up
root@OpenWrt:~# iw phy0-ap0 info
Interface phy0-ap0
        ifindex 14
        wdev 0x3
        addr 94:10:3e:98:18:a7
        ssid OpenWrt
        type AP
        wiphy 0
        channel 2 (2417 MHz), width: 20 MHz, center1: 2417 MHz
        txpower 20.00 dBm
        multicast TXQ:
                qsz-byt qsz-pkt flows   drops   marks   overlmt hashcol tx-bytes        tx-packets
                0       0       0       0       0       0       0       0               0

You can use hostapd_cli from hostapd-utils to tell hostapd to switch channels.

1 Like