User Tools

Site Tools


Wifi Toggle

:!: There is a package called 'wifitoggle' that does the same thing as the scripts below but is more advanced and has configuration. See Wifi ON OFF buttons

The scripts below allow the use of the SES button to enable or disable the wireless, this is achieved by adding a hotplug handler which reacts on button press events and a toggle script which enables or disabled the wireless depending on the current state.

Note: If you are using wireless encryption, nas and radius daemons will not be turned off during toggle and will continue to occupy cpu/memory. They should not consume too many resources with no client load though.

Toggle Script

At the beginning, create a file called woggle in /sbin and paste the content of the script into it.
Then make the file executable with the chmod +x /sbin/woggle command.

New script

This new revision aims to fix the issues previously noticed with the old script. It also uses the commands wifi up and wifi down that are supposed to be the right way to turn on or off the device.

#!/bin/sh device=“wl0” case $(uci get wireless.$device.disabled) in 0) wifi down $device echo 0 > /proc/diag/led/ses_white echo 2 > /proc/diag/led/wlan echo 1 > /proc/diag/led/power uci set wireless.$device.disabled=1 echo “Wifi disabled” ;; 1) uci set wireless.$device.disabled=0 wifi up $device echo 1 > /proc/diag/led/ses_white echo “Wifi enabled” ;; esac

Don't forget to change the value of device according to your case.

Old script

#!/bin/sh case “$(uci get wireless.@wifi-device[0].disabled)” in 1) uci set wireless.@wifi-device[0].disabled=0 wifi echo 1 > /proc/diag/led/ses_white ;; *) uci set wireless.@wifi-device[0].disabled=1 wifi echo 0 > /proc/diag/led/ses_white echo 2 > /proc/diag/led/wlan ;; esac

Hotplug Handler

To get hotplugging working, create a directory in /etc/hotplug.d called button and then create a file in /etc/hotplug.d/button called 01-radio-toggle. Paste the following content into that file:

#!/bin/sh if [ “$BUTTON” = “ses” ] && [ “$ACTION” = “pressed” ] ; then ( sleep 1; /sbin/woggle ) & fi

Now, every time you want to turn the wireless on or off, you can press the button on the router, or you can issue a woggle command from the OpenWrt shell.

docs/guide-user/network/wifi/wifitoggle.txt · Last modified: 2018/06/10 20:45 by bobafetthotmail