OpenWrt Forum Archive

Topic: [Request] for developpers: WIFI physical switch with ez-setup WL-500gP

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

Dear developpers and friends users,

as explained in the post : https://forum.openwrt.org/viewtopic.php?id=30680

I want to be able to switch on / off the WIFI of my routeur (ASUS WL-500g Premium) with a physical switch (like the already ez-setup button on this specific routeur). The reason of this need is my routeur stay connected without WIFI enabled. And if I need to connect with my smartphone I must need to enable the WIFI by first connecting a computer to switch it on an then off. That sound so stupid and could be solved with a physical WIFI switch like those we can find on some portable computers.

Somebody already made it on the Oleg firmware.
http://wl500g.info/showthread.php?t=12620

1) Do you know if this procedure will work (given code) on the OpenWRT firmware (or please give adapted code),
2) Could you please made this point available in the next version of OpenWRT ?

Sincerely thanks and have a nice day,

Miguipda ;-)

try to install package

wifitoggle                   Script to toogle WiFi with a button and UCI config

hi guys,

did anyone manage to set this up on a wl-500gp v2 running RC5?

I tried wifitoggle package, but doesn't work.

Did some debugging and found the followings:

1. If I press ez-setup while wifi is off, hotplug catches the event and triggers wifi up , but wifi up generates some additional ses and reset events, and don't know why sad, and afterwards while wifi is on hotplug doesn't catch button events at all .

2. if I switch wifi off by wifi down from command line, then hotplug catches button events again.

any idea what's the relation between wifi and buttons or hotplug??


here's my code:

root@OpenWrt:~# cat /etc/hotplug.d/button/01-wifitoggle
#!/bin/sh
logger $BUTTON
logger $ACTION
lock_file="/tmp/last_wifi_toggle"
if [ "$BUTTON" = "ses" ] && [ "$ACTION" = "released" ] && [ ! -e $lock_file ] ; then
        touch $lock_file
        echo "rm -f $lock_file" | at now + 5 minutes
        ( sleep 1; /sbin/woggle ) &
fi
root@OpenWrt:~#


root@OpenWrt:~# cat /sbin/woggle
#!/bin/sh
case "$(uci get wireless.@wifi-device[0].disabled)" in
        1)
                logger wifion
                uci set wireless.@wifi-device[0].disabled=0
                wifi up
                echo 1 > /proc/diag/led/wlan
        ;;
        *)
                logger wifioff
                uci set wireless.@wifi-device[0].disabled=1
                wifi down
                echo 0 > /proc/diag/led/wlan
        ;;
esac


and some logs:

Jun 22 23:04:17 OpenWrt user.notice root: ses
Jun 22 23:04:17 OpenWrt user.notice root: pressed
Jun 22 23:04:17 OpenWrt user.notice root: ses
Jun 22 23:04:17 OpenWrt user.notice root: released
Jun 22 23:04:18 OpenWrt user.notice root: wifion
Jun 22 23:04:19 OpenWrt daemon.info hotplug: name=wlan0, path=/devices/ssb0:3/net/wlan0
Jun 22 23:04:20 OpenWrt user.info kernel: b43-phy0: Loading firmware version 410.2160 (2007-05-26 15:32:10)
Jun 22 23:04:20 OpenWrt user.notice root: reset
Jun 22 23:04:20 OpenWrt user.notice root: pressed
Jun 22 23:04:20 OpenWrt user.notice root: ses
Jun 22 23:04:20 OpenWrt user.notice root: pressed
Jun 22 23:04:25 OpenWrt daemon.info hotplug: name=hw_random, path=/devices/virtual/misc/hw_random
Jun 22 23:04:25 OpenWrt daemon.info hotplug: name=hw_random, path=/devices/virtual/misc/hw_random
Jun 22 23:04:25 OpenWrt user.info kernel: b43-phy0: Loading firmware version 410.2160 (2007-05-26 15:32:10)
Jun 22 23:04:25 OpenWrt daemon.info hotplug: name=mon.wlan0, path=/devices/ssb0:3/net/mon.wlan0
Jun 22 23:04:26 OpenWrt user.notice root: reset
Jun 22 23:04:26 OpenWrt user.notice root: released
Jun 22 23:04:26 OpenWrt user.notice root: ses
Jun 22 23:04:26 OpenWrt user.notice root: released
Jun 22 23:04:26 OpenWrt user.notice root: reset
Jun 22 23:04:26 OpenWrt user.notice root: pressed
Jun 22 23:04:26 OpenWrt user.notice root: ses
Jun 22 23:04:26 OpenWrt user.notice root: pressed
Jun 22 23:04:31 OpenWrt daemon.info hotplug: name=hw_random, path=/devices/virtual/misc/hw_random
Jun 22 23:04:31 OpenWrt user.info kernel: device wlan0 entered promiscuous mode
Jun 22 23:04:31 OpenWrt user.info kernel: br-lan: port 2(wlan0) entering forwarding state
Jun 22 23:04:34 OpenWrt user.info kernel: device wlan0 left promiscuous mode
Jun 22 23:04:34 OpenWrt user.info kernel: br-lan: port 2(wlan0) entering disabled state
Jun 22 23:04:34 OpenWrt user.info kernel: device wlan0 entered promiscuous mode
Jun 22 23:04:34 OpenWrt user.info kernel: br-lan: port 2(wlan0) entering forwarding state


this is the result of one ez-setup button press while wifi is off. you can see one ses pressed then ses released what is the expected behavior, than my wifion message, this is fine, but than there are some additional events caught by hotplug. I created /tmp/last_wifi_toggle and after 5 minutes deleting it via at to avoid hotplug catching the auto generated events by wifi up.

appreciate any idea.

thank you!

Dear basil,

thanks for your great idea to install wifitoggle package.
I did it but still have a little problem.

After installation it well created the 50-wifitoggle in the /etc/hotplug.d/button folder.

Then after I installed this new package I rebooted the router.
I test it with the ez-setup button and even with the reset one. But both did not react on this pressed button.
Then I tested with a long press (15 sec). Nothing changed too.

Then I read this 50-wifitoggle file and saw the "wps" name was use for this ez-setup button.
As I previously tried the Preliminary step (on this page : http://wiki.openwrt.org/doc/howto/hardware.button) to see what was the real button name for both ez-setup and reset I discovered the ez-setup button name is "ses". Then I also tried  after having changed the "wps" button name by the "ses" name. And after a reboot it still did not worked. Even the wireless led does switch on or off even the wireless (in Luci) status does change.

I even read the log file by using the logread command line to see if something was triggered when I pressed those two buttons. Nothing changed.

Could you please tell me what must I still do to get it work ?

Another thing. As explained at the end of the Ecample 5 on this link : http://wiki.openwrt.org/doc/howto/hardware.button
he proposed to use it with script to allow us to run it to disabling wifi during the time we are sleeping (or gone to work).
Then how could I simulate the pressed ez-setup to run your wifitoggle package and get the same script effect (on/off) ?

Sincerely thanks and have a nice day,

Miguipda ;-)

Then was did I missed after having installed this wifitiggle package ?

(Last edited by miguipda on 20 Oct 2012, 16:12)

Hi,

some news about this previous remark ?

Have a nice day,

Miguipda ;-)

The discussion might have continued from here.