Router Webinterface (192.168.1.1) ->
Services ->
Services ->
SES / AOSS / EZ-SETUP / WPS Button ->
Turning off radio -> Enable
Does not work. Pressing the button seems to do something to the QSS-LED. QSS-LED turnes off but then turns on after 1-2 seconds. WiFi stays on.
Turn radio off at boot -> Enable does not work either. Maybe there is a connection between those two options?
Any idea how to fix it?
QSS Button on this router is gpio number 12.
"1" when not pressed
"0" when pressed
Last edited by daheist on Sun Aug 19, 2012 20:43; edited 3 times in total
I tried using the following script. I did not write it myself, but modified it to suit my router.
I put comments in the script behind the number sign '#' so that you can understand what I'm trying to do.
(Note that I use the QSS LED (gpio number 0) as W-LAN on/off indicator since you can not really control the W-LAN LED, which apparentely is gpio number 33. QSS button is gpio number 12)
# START OF SCRIPT
#!/bin/sh
while : ; do # This is the start of the loop
WIFI=`nvram get ath0_net_mode` # get mode in variable WIFI
sleep 1;
if [ "$(cat /proc/gpio/12_in )" = "0" ]; then # is QSS button pressed? If so, then... if [ "$WIFI" == "disabled" ]; then # check if the ath0_net_mode is disabled, we need to turn wifi on then
nvram set ath0_net_mode=mixed # turn it on by setting mixed
/sbin/ifconfig ath0 up # bring interface up
/sbin/gpio disable 0 # light up QSS LED
echo "1" > /proc/gpio/12_in # I dontr really know what this does.
sleep 3
else # run this code if wifi is on and want to turn it off
nvram set ath0_net_mode=disabled # set mode to disabled
/sbin/ifconfig ath0 down # shut interface down
/sbin/gpio enable 0 # turn LED off
echo "1" > /proc/gpio/12_in
sleep 3
fi fi done & # end of loop
# END OF SCRIPT
Blue is the loop of the script that gets executed since the script is startet on startup of the router. Green is the request where it checks whether the button is pressed (0) or not (1). Red is the request whether wifi is on or not. if wifi is on (ath0_net_mode=mixed), it turns it off. If wifi is off (ath0_net_mode=disabled), it turns it on.
So, I saved it to run on startup. You might think it would work. At least thats what I tought.
What happens:
I turn the router on. After boot wifi is on. You can access network via wifi without problems. QSS LED on (don't ask me why). wifi LED is on.
Now I want to turn wifi off without having to access the webinterface. So I press the QSS button. *press*. QSS LED turns off. wifi LED stays on. wifi still visible. wifi connection breaks. wifi still visible. Computer tries to reconnect, but fails. Shortly after, wifi connection not visible anymore. wifi LED still on.
I try to turn it on again. Pressing QSS button. QSS LED turns on. wifi LED still on. wifi visible. Computer can't connect to network. Only solution is reboot of router.
End of Story.
I can turn wifi on/off via Webinterface. The wifi LED then does turn on and off accordingly. So in principle, it can be done. But not with my script. I need to know what has to be done or what the webinterface does to turn it on/off.
It seems like the wifi LED is a reliable indicator of whether the wifi is really (by that I mean the wifi hardware) on or off.
So what the heck do I want?
I want the QSS button to turn the wifi hardware on or off. And I want it to work reliable.
Last edited by daheist on Sun Aug 19, 2012 20:41; edited 1 time in total
Sucess!
The script works.
wifi can now be toggled on and off with the QSS button.
It was actually very easy. But it took me hours and I tried and tried and looked around with telnet and so on.
How did I find it out?
Simple. I ran the command "ps" which shows every process. With wifi on, there is a process "hostapd". Witout wifi, the process is gone. Killing the process turns wifi off. Creating the process turns wifi on.
Command to turn wifi on:
hostapd -B /tmp/ath0_hostap.conf
That's it!
Running these commands really turns on and off the hardware. In idle and with wifi turned off the router is at 250mA @ 9V. In idle and with wifi turned on, the router is at 295mA @ 9V. And it turns on and off the wifi LED accordingly. Great! Exactly what I wanted.
Here is my corrected startup script. Line 2, 3 and 4 is for turning off wifi at startup. If you want wifi to be turned on at startup, simply delete those three lines from the code.
Code:
#!/bin/sh
nvram set ath0_net_mode=disabled
/sbin/ifconfig ath0 down
kill `ps | grep "hostapd" | awk '{print $1}'`
while : ; do
WIFI=`nvram get ath0_net_mode`
sleep 1;
if [ "$(cat /proc/gpio/12_in )" = "0" ]; then
if [ "$WIFI" == "disabled" ]; then
nvram set ath0_net_mode=mixed
/sbin/ifconfig ath0 up
hostapd -B /tmp/ath0_hostap.conf
echo "1" > /proc/gpio/12_in
sleep 3
First, instead of killing hostapd I would generally do stopservice lan and then startservice lan when I want it back. It is less dirty. The problem is that my solution does disable even the wired ports but if you are fine with that - proceed my way.
Second, I would never do nvram set from a script. Imagine if something (or you accidentally) does a nvram commit while ath0_net_mode is disabled? For example ttraff makes commit on some usage statistics or upnp commits some forwardings etc. If a commit occurs at a time when wifi is disabled, it will always be disabled on boot until you commit it manually to be on.
Posted: Mon May 05, 2014 8:03 Post subject: [SOLVED] for v3, maybe
same device as previous poster, a v3, and the build is 23919 (latest). Script is copied into Startup Commands script box, saved, device rebooted, and it does not turn on when pressing the button.
------------------
[SOLVED]
On the v3, change the GPIO reference in the above script, from "12" to "1".
I tried to re-write the script:
But the radio is normally off, then when pressing the button, only is on for a few seconds then turns off again. :/
Code:
#!/bin/sh
/sbin/ifconfig ath0 down # turn the radio off
nvram set hostap_radio_status=off # set the saved value of the on/off variable to off
while : ; do # begin a loop
WIFI=`nvram get hostap_radio_status` # get the current value of the variable radio on/off
sleep 1;
if [ "$(cat /proc/gpio/1_in )" = "0" ]; then # if the status of the button is pushed-in on the back of the unit:
WIFI=`nvram get hostap_radio_status` # get the current value of the variable radio on/off
if [ "$WIFI" == "off" ]; then # if the current value of the radio is off
/sbin/ifconfig ath0 up # turn the radio on
nvram set hostap_radio_status=on # turn the variable radio_status to 'on'
echo "1" > /proc/gpio/1_in # set the gpio value to 1 (off)
sleep 5
else # otherwise if the variable for the radio is not 'off', e.g. 'on', then
/sbin/ifconfig ath0 down # turn the radio off
nvram set hostap_radio_status=on # turn the variable radio_status to 'off'
echo "1" > /proc/gpio/1_in # set the gpio value to 1 (off)
sleep 5
fi
fi
done &
I am sure i did something wrong with this script but I don't care for this geeky stuff. _________________ various hw
Posted: Tue May 06, 2014 17:43 Post subject: Re: [SOLVED] for v3, maybe
hoot_spoot wrote:
same device as previous poster, a v3, and the build is 23919 (latest). Script is copied into Startup Commands script box, saved, device rebooted, and it does not turn on when pressing the button.
------------------
[SOLVED]
On the v3, change the GPIO reference in the above script, from "12" to "1".
I tried to re-write the script:
But the radio is normally off, then when pressing the button, only is on for a few seconds then turns off again. :/
Code:
#!/bin/sh
/sbin/ifconfig ath0 down # turn the radio off
nvram set hostap_radio_status=off # set the saved value of the on/off variable to off
while : ; do # begin a loop
WIFI=`nvram get hostap_radio_status` # get the current value of the variable radio on/off
sleep 1;
if [ "$(cat /proc/gpio/1_in )" = "0" ]; then # if the status of the button is pushed-in on the back of the unit:
WIFI=`nvram get hostap_radio_status` # get the current value of the variable radio on/off
if [ "$WIFI" == "off" ]; then # if the current value of the radio is off
/sbin/ifconfig ath0 up # turn the radio on
nvram set hostap_radio_status=on # turn the variable radio_status to 'on'
echo "1" > /proc/gpio/1_in # set the gpio value to 1 (off)
sleep 5
else # otherwise if the variable for the radio is not 'off', e.g. 'on', then
/sbin/ifconfig ath0 down # turn the radio off
nvram set hostap_radio_status=on # turn the variable radio_status to 'off'
echo "1" > /proc/gpio/1_in # set the gpio value to 1 (off)
sleep 5
fi
fi
done &
I am sure i did something wrong with this script but I don't care for this geeky stuff.
I've tried both 1 and 12, it doesn't work for me. I have v3 unit.
Okay, this is the script which works for me, but I can only toggle it directly from shell (via ssh) with command "gpio enable 1":
Code:
#!/bin/sh
/sbin/ifconfig ath0 down
nvram set hostap_radio_status=off
while : ; do
sleep 1;
if [ "$(cat /proc/gpio/1_in )" = "1" ]; then
WIFI=`nvram get hostap_radio_status`
if [ "$WIFI" == "off" ]; then
/sbin/ifconfig ath0 up
nvram set hostap_radio_status=on
gpio disable 1
sleep 5
else
/sbin/ifconfig ath0 down
nvram set hostap_radio_status=off
gpio disable 1
sleep 5
fi
fi
done &
When I press SES button, nothing happens, it does not trigger anything. :/