1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

turn wifi on/off automatic

Discussion in 'Tomato Firmware' started by kultex, Jan 6, 2009.

  1. kultex

    kultex Addicted to LI Member

    !solved! - turn wifi on/off automatic

    I am searching a way to turn on/off wifi periodically in the webif.

    Background - a friend of mine has a brain cancer, but she also has 2 young boys, who do not want to turn off wifi definitive. So I am searching for a way, to do this in the webif (not in cron), thus they can control this.

    Looking around, I found, that this could be possible with tomato with the script and scheduler function.

    I use openwrt - I have now idea of tomato - I was using a script in openwrt and cron to do this:

    Code:
    #!/bin/sh
    #
    # Turns WI-FI on/off.  Used with crond.
    
    case "$1" in
        on)
            if [ $(nvram get wl0_radio) = 0 ]; then
            {
                nvram set wl0_radio=1
                nvram set wl0_akm="psk psk2"
                sleep 1
                wifi
                ifup wifi
                /etc/init.d/S41wpa
            }
            fi
        ;;
        off)
            if [ $(nvram get wl0_radio) = 1 ]; then
            {
                ifdown wifi
                killall nas >/dev/null 2>&1
                sleep 1
                nvram set wl0_radio=0
                nvram set wl0_akm="none"
                sleep 1
                wifi
                echo 1 > /proc/diag/led/power
            }
            fi
        ;;
        *)
            echo $"Usage: $0 {on|off}"
            exit 1
        ;;
    esac
    the script comes from here: http://forum.openwrt.org/viewtopic.php?id=8373

    perhaps you have an idea, if this could work in tomato or how to change it
     
  2. Planiwa

    Planiwa LI Guru Member

    Some of the following may be helpful:

    1. Push the Cisco button for 1 second to toggle WiFi at will. (See Administration > Buttons/LED)

    2. Use Access Restrictions to set up multiple WiFi-Disabled time periods.

    The following command tools may be useful:

    wl radio off
    wl radio on
    wl down # this also makes the power light flash
    wl up
    wl isup # is it enabled? (this is better than the next one) [Edit]
    cat /proc/net/wl0 # is it enabled?
     
  3. kultex

    kultex Addicted to LI Member

    tank you - I think like this it should work - I have to test it .....

    Code:
    #!/bin/sh
    #
    # Turns WI-FI on/off.
    
    case "$1" in
        on)
            if [ $(nvram get wl_radio) = 0 ]; then
            {
                nvram set wl_radio=1
                wl radio on
            }
            fi
        ;;
        off)
            if [ $(nvram get wl_radio) = 1 ]; then
            {
                nvram set wl_radio=0
                wl radio off
            }
            fi
        ;;
        *)
            echo $"Usage: $0 {on|off}"
            exit 1
        ;;
    esac
     
  4. kultex

    kultex Addicted to LI Member

    the commands work, but the script does not ....
     
  5. Planiwa

    Planiwa LI Guru Member

    If the commands work, why not just simply use them, all by themselves?

    Or why not just use the "Access Restriction" web page, which appears to fit your requirement for a GUI solution?

    Simply check the circle that says "Disable Wireless" beside it.
     
  6. kultex

    kultex Addicted to LI Member

    I was somehow script fixed .... "Access Restriction" works perfect, thank you....
     

Share This Page