Page 1 of 4

WiFi button not supported

Posted: Tue Jun 09, 2015 6:20 pm
by wazahuis
Hi,

Just got a NetGear router. These have a WiFi button that turns the WiFi off or on without having to log into software. Great for kids if you want to turn off their access fast or on etc.

Unfortunately those buttons don't work with Gargoyle. I would assume this would be a fairly simple feature to support?

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 6:32 pm
by harptastic
I too have recently install Gargoyle onto my NETGEAR WNDR3800 and love all the features. However, I cannot find a way to enable the wifi button on the front of the router. If anyone know of a way that would be greatly appreciated. :D

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 6:35 pm
by nworbnhoj
wazahuis wrote:Just got a NetGear router. These have a WiFi button that turns the WiFi off or on without having to log into software. Unfortunately those buttons don't work with Gargoyle. I would assume this would be a fairly simple feature to support?

It will depend entirely on OpenWRT support as Gargoyle is built on OpenWRT.

http://wiki.openwrt.org/toh/start#netgear

What model router are you using?

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 6:45 pm
by wazahuis
I am using Netgear WNDR3800

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 8:43 pm
by Lantis
we can get you both up and running if you are willing to do some very basic coding.

You will need:
PuTTY.exe (or your favourite SSH client)
WinSCP

log into your router with both of these programs, defaults are:
hostname: 192.168.1.1
port: 22
username: root
password: yourpassword

in WinSCP make sure you set File Protocol to SCP, and also tell it to remember your password for the session or you will be typing it over and over.


in WinSCP navigate to "/etc/hotplug.d/button"
and open "00-button" for editing.

add the following line as shown:

Code: Select all

logger the button was $BUTTON and the action was $ACTION

Code: Select all

	[ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && {
		[ -z "$min" -o -z "$max" ] && eval $handler 
		[ -n "$min" -a -n "$max" ] && {
			[ $min -le $SEEN -a $max -ge $SEEN ] && eval $handler 
		}
	}
	logger the button was $BUTTON and the action was $ACTION
}
i.e. make sure it goes between the 2nd last and last braces.
Save and close, wait until the changes have uploaded.

go and press the button on your router that you wish to have as your wifi toggle button.
in PuTTY, type "logread".
look for the following phrase
"user.notice.root: the button was XXX and the action was pressed/released"
write this button name down exactly as stated, we will need it soon. for the fellow with the WNDR3800 it should be BTN_2.

now in PuTTY type
cd /etc
touch wifitoggle.sh
chmod +x wifitoggle.sh

using WinSCP, find the file "wifitoggle.sh" in /etc and put the following into it

Code: Select all

#!/bin/sh

STATUS=`wifi status | grep -m 1 up | sed -e 's/^[ \t]*//' -e 's/"up": //'`

if [ "$STATUS" == "true," ]; then
	wifi down
	logger Wifi button pressed, wifi going down
else
	wifi up
	logger Wifi button pressed, wifi going up
fi
now back to PuTTY (i promise we are almost done) issue the following commands

uci set system.wifi_toggle=button
uci set system.wifi_toggle.button=BTN_2 <-- or whatever the name of the button was we found earlier
uci set system.wifi_toggle.action=pressed
uci set system.wifi_toggle.handler=/etc/wifitoggle.sh
uci commit system


test it out and see what happens.

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 9:47 pm
by harptastic
Thanks for that information but it sounds like a lot of messing around, but it's good that you can add features like that.
Also I've had a look but was unable to find a plugin that could do the same. I was wondering if there was a plugin somewhere that would not be router dependant or have I missed some info on what plugin can and cannot do.

Thanks Heaps

Re: WiFi button not supported

Posted: Tue Jun 09, 2015 10:34 pm
by Lantis
Any plugin that implemented this feature would do it the same way I did, just making the process automated.

They would probably use a nicer detection method though. I used the first thing I could think of.

Re: WiFi button not supported

Posted: Wed Jun 10, 2015 6:23 pm
by wazahuis
So no plug-in's available to do this?

I would be happy for someone to code this up and pay for it and you could give me a price? And then it can become public domain.

Re: WiFi button not supported

Posted: Wed Jun 10, 2015 9:31 pm
by Lantis
Which netgear router did you have?

Re: WiFi button not supported

Posted: Wed Jun 10, 2015 9:56 pm
by wazahuis
I have a NETGEAR WNDR3800