Results 1 to 13 of 13

Thread: How to disable the radio whenever possible

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    How to disable the radio whenever possible

    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

  2. #2
    clever

    I may have to try this sometime...

  3. #3

    Question NICE SOLUTION but ...PLEASE COULD YOU...

    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 ... )

  4. #4

    step by step

    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

  5. #5
    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.)

  6. #6
    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
    Last edited by xplay; 09-11-2008 at 23:23.

  7. #7
    Join Date
    Apr 2008
    Location
    ãîðîä ñàìîâàðîâ è ïðÿíèêîâ
    Posts
    1,492
    knulp79
    Can you explain me, please, how can I program the EZ button by any user code, not only for switch on/off radio.

  8. #8
    Join Date
    Apr 2009
    Location
    Sofia,Bulgaria
    Posts
    29
    Hi,

    I'm not sure what this code is doing and is it necessary ?
    Code:
    while [ $C -gt 0 ]; do
    printf "\x02" > /dev/gpio/out
    sleep 1
    printf "\x00" > /dev/gpio/out
    sleep 1
    I wrote myself a short code , which can be used also if you have enabled cron. In the /usr/local/sbin/ez-setup file I wrote simple code just to switch on/off the wireless. If you remove thecomments it is only 4-5 rows.
    Code:
    #!/bin/sh
    WLAN=`wl isup`
    time=`/bin/date '+%b %e %H:%M:%S'`
    if [ "$WLAN" = "0" ]; then
        echo "$time: Wireless was down, powering up!" >> /tmp/var/log/ez-setup.log && wl radio on
        echo "$time : You have 5 minutes to  connect to the router before wireless automatically shuts down" >> /tmp/var/log/ez-setup-pressed
        sleep 300
        echo "$time : End of 5 minutes" >> /tmp/var/log/ez-setup.log
        rm /tmp/var/log/ez-setup-pressed
     else
        echo "$time: Wireless was up, powering down!" >> /tmp/var/log/ez-setup.log && 
        wl radio off
    fi
    When I press the ez-setup, it starts/stops the wireless and creates "flag" file in order to mark that the button was pressed.

    Then in the cron I start the following script to disable the wireless if it is not used. The purpose of the "flag" file is to assure that the wireless will be on for at least 5 minutes, so we can connect. Without it it may happen that we will switch on the wireless and in 10 seconds cron may stop it.
    You may put this code in a script and start it every 5 minutes using cron.
    Code:
    #!/bin/sh
    
    time=`/bin/date '+%b %e %H:%M:%S'`
    
    WLAN=`wl isup`
    if [ "$WLAN" = "0" ]; then
    #echo "$time : Wireless is already down ! " >> /opt/var/log/ez-setup.log
    exit
    fi
    
    if [ -f /tmp/var/log/ez-setup-pressed ]; then 
    #echo "$time : Stop file still exists" >> /opt/var/log/ez-setup.log 
    exit
    fi
    
    if [ $(wl assoclist | wc -l) -gt 0 ]; then 
    #echo "$time : Wireless devices still connected" >> /opt/var/log/ez-setup.log 
    exit
    fi
    
    echo "$time : Wireless automatically down " >> /tmp/var/log/ez-setup.log 
    wl radio off
    Last edited by zerg; 26-09-2009 at 21:10.

  9. #9

    wifi led working disable other

    Hy in this new (latest version) of oleg wifi led it turns off and on with the wireless device , so i do not need the power led to blink, wich line i take it out from the original code here to stop the power led blinking ??


    10x

    BTW , great work with ez button

  10. #10

    How to turn wireless on / off with EZ-SETUP button

    Quote Originally Posted by tmsulica View Post
    Hy in this new (latest version) of oleg wifi led it turns off and on with the wireless device , so i do not need the power led to blink, wich line i take it out from the original code here to stop the power led blinking ??
    I don't know what you mean by the original code.
    I'm using 1.9.2.7-d-r740 and the wireless led turns on/off automatically with 'wl radio on' and 'wl radio off' commands.

    Here's a simple script which turns wireless on/off and logs the event to syslog when ez-setup is pressed:

    Code:
    #!/bin/sh
    WLAN=`wl isup`
    if [ "$WLAN" = "0" ]; then
        logger -t EZ-SETUP "button pressed: wireless turned ON" && wl radio on
     else                                                                     
        logger -t EZ-SETUP "button pressed: wireless turned OFF" && wl radio off
    fi
    Edit: and the script in question is of course /usr/local/sbin/ez-setup
    Last edited by RDF; 24-01-2010 at 10:27. Reason: edit2: changed to use logger instead of directly echoing to syslog.log

Similar Threads

  1. help pls! radio doesn't work in 1.9.7.5 firmware
    By anpspb in forum WL-500gP Q&A
    Replies: 12
    Last Post: 26-01-2008, 20:41
  2. How can I disable radio?
    By maradamc in forum WL-500gP Firmware Discussion
    Replies: 6
    Last Post: 22-01-2008, 22:19
  3. Scripting or automatic disable Radio
    By airone in forum WL-500g Q&A
    Replies: 2
    Last Post: 15-12-2005, 15:39
  4. Disable radio
    By Marrik in forum WL-500g Q&A
    Replies: 8
    Last Post: 26-02-2005, 17:04
  5. The right way to disable radio (physical)
    By mamici in forum WL-500g Q&A
    Replies: 2
    Last Post: 04-11-2004, 15:41

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •