The WRT54GL router has two buttons: one reset button and one called "SecureEasySetup" or SES. After OpenWRT installation this two button do not served. We will see how to give a role to the SES one to toggle the wifi on and off.
Wifi toggle script
First we will create a script that allow us to change the wifi status. It will activate the wifi when it is not and inactivate it otherwise. In addition it will change the WLAN LED status according to the wifi status.
For that, we will create the file /sbin/woggle
(for wifi toogle), that
contain:
#!/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
The script first grabs the wifi status (uci get
wireless.@wifi-device[0].disabled
). If it deactivated (ie equal to 1
),
it actives it and switch on the LED of the SES button. Otherwise it deactivates
the wifi switch off the LED of SES button and let the WLAN LED blink once.
After creation do not forget to set it executable with the following command:
# chmod +x /sbin/woggle
To change the wifi status and test the command, you can run the script with the following command:
# /sbin/woggle
Link with the SES button
Now that e have the script to toggle the wifi, we need to link it with the SES button. Like this it will be execute each time the SES button is pressed.
It is handle by the hotplug events. For this it is needed top create the
button
directory in the /etc/hotplug.d
directory. Then in that
newly created directory create a script with a name like the following
01-radio-toggle
contenting:
#!/bin/sh
if [ "$BUTTON" = "ses" ] && [ "$ACTION" = "pressed" ] ; then
( sleep 1; /sbin/woggle ) &
fi
Now to activate or deactivate the wifi you only need to press the SES button.