OpenWrt Forum Archive

Topic: [Howto] WiFi toggle

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

WiFi toggle

Moved to Wiki: http://wiki.openwrt.org/OpenWrtDocs/Cus … WifiToggle


14.09.2007 Move to Wiki page: WifiToggle.
08.09.2007 Rewrite the hotplug script to work with Atheros and Broadcom WiFi. Use a UCI configuration file to configure the button.

(Last edited by forum2006 on 14 Sep 2007, 12:29)

The if [ "$ACTION" = "pressed" ] line may mitigate this, but I use a hotplug script to toggle ports via my SES button, and I use:

if [ $BUTTON == "ses" ] && [ $SEEN != "0" ];

Without checking $SEEN, I had problems if I hit the button twice too fast (which I don't normally do, but I didn't want unexpected results should I get button-happy). smile

I'm getting the wifitoggle mod to turn on correctly by pressing reset button, which is verified by "cat /etc/config/wireless" where disabled=0 AND the AIR led turns on.

But when I press the button again wifi turns off (in /etc/config/wireless) but the AIR led is still on. When the router is rebooted the AIR led turns off.

Shouldn't the AIR led turn off when pressing the button a second time (disabling wifi)?

tonyboy: same issue here... sad i hope somebody could help as...

IIRC on most routers you cannot control the WiFi LED.

I've created a package called wifi toggler, check https://dev.openwrt.org/ticket/2855 . this package is for atheros based routers but might be modified to support other hw platforms aswell. the only atheros dependen task is to enable or disable the led.

cheers

(Last edited by michu on 24 Dec 2007, 09:20)

Because I couldn't find the wiki page posted, here the short description I was missing out on in the beginning. I'm using Kamikaze 7.09 and to make it work there you need to install the "hotplug2" package first. With my system some hotplug scripts already came (the ones required for booting) without the hotplug2 engine itself. That confused me a bit.

I put this script in /etc/hotplug.d/button/30-button-trigger:

if [ "${ACTION}" == "released" ]
then
        /usr/sbin/wlan-button
fi

Whenever any button is "released", the /usr/sbin/wlan-button script is started. It looks like this:

#!/bin/sh

if [ `wlc radio` == "1" ]
then
        wlc radio 0
else
        wlc radio 1
fi

I leave it as an exercise to the implementor to make it work only with the "ses" button. wink

forum2006 wrote:

WiFi toggle

Moved to Wiki: http://wiki.openwrt.org/OpenWrtDocs/Cus … WifiToggle


14.09.2007 Move to Wiki page: WifiToggle.
08.09.2007 Rewrite the hotplug script to work with Atheros and Broadcom WiFi. Use a UCI configuration file to configure the button.

There's one side effect of the Alternative Script. If issue "uci commit" or just "uci commit wireless" while wireless being turned off, wireless will be off on the next boot. And if wireless is off initially, there's a chance that executing the "/sbin/woggle" script might sometimes crash the router. It happened once or twice on me but I can't be sure exactly how. Can't be sure whether the script has fully initialized the wireless interface or not.

Could it be some services of the wireless interface being down initially? What should be done in the custom_user_startup script before executing the /sbin/woggle script if the wireless is off initially?

Edit:
Just found the new wiki of Wifi Toggle. Comparing with the old wiki, there're several modifications in the new wiki.
OpenWrtDocs/Customizing/Software/WifiToggle (old wiki)
Wifi Toggle Script - OpenWrt Wiki (new wiki)

(Last edited by fyi on 24 Apr 2010, 07:17)

The discussion might have continued from here.