OpenWrt Forum Archive

Topic: How to disable/enable different wifi networks from cmmand line

The content of this topic has been archived on 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Have two wifi connections in the luci (Network->WiFi) with essid:
WIFI1
WIFI2
Need to  write several bash-script files wich will switch connections to disable/enable state:
bash-script1:
WIFI1->enable
WIFI2->disable
or
bash-script2:
WIFI1->disable
WIFI2->enable
cat /etc/config/wireless:

config wifi-device 'radio0'
        option type 'mac80211'
        option hwmode '11g'
        option path 'platform/qca953x_wmac'
        option htmode 'HT20'
        option txpower '19'
        option country 'US'
        option channel '9'

config wifi-iface             
        option device 'radio0'            
        option mode 'ap'                
        option encryption 'psk-mixed'
        option ssid 'WIFI1'          
        option network 'WIFI1'      
        option key 'password'     

config wifi-iface             
        option device 'radio0'            
        option mode 'ap'                
        option encryption 'psk-mixed'
        option ssid 'WIFI2'          
        option network 'WIFI2'      
        option key 'password'     
        option disabled '1'  

Where is this script wich react to "button" in luci that switch disable/enable state of wifi connection?

(Last edited by kakzovut1712 on 25 Jun 2017, 09:37)

Don't you have any suggestions? smile
Just need to realize the function of enable button in command line:
94.fastpic.ru/big/2017/0626/85/b3aaf4a85b55e292bd52f63a8a71ee85.png

(Last edited by kakzovut1712 on 25 Jun 2017, 21:25)

Found that i can off/on wifi by next command:

/etc/profile; wifi down

But how to off/on different wifi connections..?

Use uci set and uci commit wireless. uci show will show you the names of things you can set.  It is helpful to explicitly name your interface blocks on the wifi-iface lines of /etc/config/wireless.

mk24 wrote:

Use uci set and uci commit wireless. uci show will show you the names of things you can set.  It is helpful to explicitly name your interface blocks on the wifi-iface lines of /etc/config/wireless.

With your advice, everything worked! Thank's wink
Done state of this request for me looks like this:
Wifi1.sh

uci delete wireless.@wifi-iface[0].disabled='1'
uci set wireless.@wifi-iface[1].disabled='1'
uci commit wireless
/etc/profile; wifi down
/etc/profile; wifi up

Wifi2.sh

uci set wireless.@wifi-iface[0].disabled='1'
uci delete wireless.@wifi-iface[1].disabled='1'
uci commit wireless
/etc/profile; wifi down
/etc/profile; wifi up

The discussion might have continued from here.