Quite a bit of devices come with at least one button (apart from the omnipresent reset/recovery button, which isn't convenient to press), which in the stock firmware is used for WPS, toggling wifi, or whatever, and on LEDE is not usually connected to any function.
In this article we will install and configure a package called wifitoggle, which allows us to configure one of such buttons as a wifi on/off (toggle) button.
opkg update && opkg install wifitoggle
uci show wifitoggle, you will see something like this
root@LEDE:~# uci show wifitoggle wifitoggle.@wifitoggle=wifitoggle wifitoggle.@wifitoggle.button='wps' wifitoggle.@wifitoggle.timer='600' wifitoggle.@wifitoggle.persistent='0' wifitoggle.@wifitoggle.led_enable_trigger='timer' wifitoggle.@wifitoggle.led_enable_delayon='500' wifitoggle.@wifitoggle.led_enable_delayoff='500' wifitoggle.@wifitoggle.led_disable_default='0'
wifitoggle section contains these settings:
| ||String||yes||wps||internal name of the button to use. Usually the internal name is similar to what the button did in stock firmware. See notes below this table.|
| ||Boolean||yes||0||Commit changes to wireless config file, persistent after reset. Always 0 if Timer enabled|
| ||Integer||yes||600||Seconds for wifi to be turned off, 0 for no timer|
| ||String||no||none||Led to use, see Led configuration for possible values|
| ||String||yes||timer||led trigger name, see Led configuration for other possible led trigger names|
| ||Integer||yes||500||Milliseconds to turn led on after button pressed|
| ||Integer||yes||500||Milliseconds to turn led off after button pressed|
| ||Boolean||yes||0||Led state for wifi disabled, 1 to turn it off if wifi is off|
Common internal names for button (by searching through the source code) are:
Here's a way to identify the internal name of your button if just trying the above list blindly does not work.
If the script isn't working on your wifi networks, or it works only on some but not all, try deleting and creating again the ones that don't work.
Default wifi networks look like this in the config, and it seems the script can't parse that.
wireless.default_radio0=wifi-iface wireless.default_radio0.device='radio0' wireless.default_radio0.network='lan' wireless.default_radio0.mode='ap' wireless.default_radio0.ssid='myWifi' wireless.default_radio0.encryption='psk2+tkip+ccmp' wireless.default_radio0.key='password' wireless.default_radio0.disabled='1'
This is how it looks after I deleted and created it again (and is actually working)
wireless.@wifi-iface=wifi-iface wireless.@wifi-iface.device='radio0' wireless.@wifi-iface.mode='ap' wireless.@wifi-iface.ssid='myWifi' wireless.@wifi-iface.encryption='psk2+tkip+ccmp' wireless.@wifi-iface.key='password'
Anyone that can fix the script please send a PR from the link below.
If you like to have wifi disabled after power on, set it disabled by default and then set wifitoggle to NOT save wifi state changes to permanent memory (so that whatever the state was on reboot it would reset to disabled) with the following line:
uci set wireless.@wifi-device.disabled=1 && uci set wifitoggle.@wifitoggle.persistent=0
Or add this line to /etc/rc.local or in Startup (Luci System - Startup):
uci set wireless.@wifi-device.disabled=1 && wifi