PDA

View Full Version : How to disable the radio whenever possible


knulp79
24-01-2008, 13:27
Hi!
I wanted to switch off the radio by using the ez-setup button.
Here is how I approached the question.

login (via telnet or ssh)
create /usr/local/sbin/ez-setup :
----
#!/bin/sh
TIMEOUT=45
if [ $(wl radio) = "0x0000" ]; then wl radio off; exit; fi
wl radio on
C=$TIMEOUT
while [ $C -gt 0 ]; do
printf "\x02" > /dev/gpio/out
sleep 1
printf "\x00" > /dev/gpio/out
sleep 1
if [ $(wl radio) = "0x0001" ]; then exit; fi
if [ $(wl assoclist | wc -l) -gt 0 ]; then
C=$TIMEOUT
else
C=$(($C-1))
fi
done
wl radio off
----
then
chmod +x /usr/local/sbin/ez-setup
echo "sleep 25; wl radio off" >> /usr/local/sbin/post-boot
flashfs save && flashfs commit && flashfs enable && reboot

After you turn on the WL500gp, the radio is switched off. To turn it on, you have to press the ez-setup button for a few seconds. The power led starts flashing (I could not control the air led that is always on, even if the radio is off, at least with the firmware version I am using). If within 90 seconds (2*45, but you can change this value) one client connects to the ssid the connection is maintained otherwise the radio is turned off again.
As long as at least one client is connected, the radio is kept on.
After all clients are disconnected the radio is turned off again.
If you have comments or suggestions, feel free to open a discussion.
Cheers,
Luca

hypernetics
05-04-2008, 16:38
clever :)

I may have to try this sometime...:rolleyes:

radio off
23-09-2008, 02:37
Hi all ,especially knulp79 ,
I am interested in your solution with wifi radio on /off part on this WL-500gP V2 (oleg last firm 10),
but I dont understand the right commands step by step to do it right.

so COULD you PLEASE write a small TUTORIAL how to make this your idea easy for non linux programming people ?

just write where can I find the command line and so on ...

mabye all thru putty ? or some part thru system setup /system command thru web router managememnt ?? ...

mabye not write create a file ...but exactly mkdir ... THANKS for your HELP to make this tutorial easy for SMART PEOPLE ...

OR ANYONE who understand or have these 5min to write it on base of knulp79

THANKS ,thanks thanks a lot ...

I think I am not alone who is looking for it ... :))

knulp79
23-09-2008, 10:42
Hi!
I am sorry if my instructions are not very straightforward.
I'll try to do my best.
You must access the "command line" of your wl500gp. You can do it via ssh or via telnet. I thought it was clear enough. If you expected me to write "putty", please consider that putty is just one of the many ssh clients, and that you need some prior work to enable ssh while telnet is present by default (double-check that it is enabled in the web panel). To make the long story short, get access to the prompt in some way, there are a few tutorials in this forum.
Create a file called /usr/local/sbin/ez-setup with the content below. A way to do it is to type "vi /usr/local/sbin/ez-setup". This editor, vi, is not the most intuitive for novices but you can find some tutorial online. The key commands are "i" to enter the insert text mode, ESC to go back to the command mode, and ":wq" to write and quit.
----
#!/bin/sh
TIMEOUT=45
if [ $(wl radio) = "0x0000" ]; then wl radio off; exit; fi
wl radio on
C=$TIMEOUT
while [ $C -gt 0 ]; do
printf "\x02" > /dev/gpio/out
sleep 1
printf "\x00" > /dev/gpio/out
sleep 1
if [ $(wl radio) = "0x0001" ]; then exit; fi
if [ $(wl assoclist | wc -l) -gt 0 ]; then
C=$TIMEOUT
else
C=$(($C-1))
fi
done
wl radio off
----
Then you have to enter the following instructions at the command line.
chmod +x /usr/local/sbin/ez-setup
echo "sleep 25; wl radio off" >> /usr/local/sbin/post-boot
flashfs save && flashfs commit && flashfs enable && reboot
The first one makes the script above executable. The second switches off the radio by default after the device is booted. The third line saves the new configuration (otherwise it is lost after reboot) and reboots the device.
Everything should be configured now.
I am writing this lines without access to the device, so let me know if something does not work (e.g. you can't create /usr/local/sbin/ez-setup because /usr/local/sbin/ does not exist).
I hope it helps.
Cheers,
Luca

raas
23-09-2008, 11:02
Nice tutorial79 knulp..
I suppose you can also run this script to execute something else?

(thinking of a way to stop/start HellaNZB, so I don't have to login to to that.)

xplay
08-11-2008, 22:54
it is possible to modify the script ?!
when you turn on (reboot) the router the radio to be on (work) by default - and to close only if no one connect to the ssid in a value of time ???!

Pls , any suggestions ?

i will appreciate

MrGalaxy
09-11-2008, 14:26
knulp79
Can you explain me, please, how can I program the EZ button by any user code, not only for switch on/off radio.