Table of Contents

Wifi Toggle

:!: There is a package called 'wifitoggle' that does the same thing as the scripts below.

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

Create a file called woggle in /sbin and paste the content below into it:

#!/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

Then make it executable with the chmod +x /sbin/woggle command.

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.

Back to top

doc/howto/wifitoggle.txt · Last modified: 2010/09/14 22:32 by realopty