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

WRT54Gv2 tomato on/off radio via reset button

Discussion in 'Tomato Firmware' started by andybi, Oct 14, 2008.

  1. andybi

    andybi Network Guru Member

    Hi there,I have 2 router WRT54G in the first one I use openwrt whiterussian, and I write this script to toggle the wifi on and off pressing the reset button:

    Code:
    Loaded in /etc/init.d/
    
    #! /bin/sh
    while [ true ]; do
    sleep 1
    if [ `cat /proc/sys/reset` = "1" ]; then
    x=`nvram get wl0_radio`
    case $x in 0) x=1 ;; 1) x=0 ;; esac
    nvram set wl0_radio=$x
    wifi
    fi
    done &
    Now on the second one due probably a damage on the flash the only firmware that works is tomato 1.21, great! nice interface! but is there any way to implement something similar (the script above) on tomato?

    thank you
    Andrea
     
  2. Rob650

    Rob650 Addicted to LI Member

    Does the WRT54G v2 have a SES button on the front? If so you can toggle wireless using that. Go to Administration > Buttons / LED to set it up.
     
  3. andybi

    andybi Network Guru Member

    no it doesn't!
    I need to do this with the reset button!!!

    Thank you

    Andrea
     
  4. Mastec

    Mastec Network Guru Member

    Didn't WRT54G series routers come with an SES button? They just need the right firmware to activate it prior to version 3.1. My version 3 has one and works flawlessly
     
  5. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    Version 3 was the first to include the button.
     
  6. Mastec

    Mastec Network Guru Member

    Ah... OK. Thanks for the info
     
  7. SgtPepperKSU

    SgtPepperKSU Network Guru Member

    You can't do this without firmware changes. Currently, it is hard-coded to reboot if you hold it less than 3 seconds, reset nvram+reboot if you hold it longer. However, if you are feeling up to the task, I think the following is all that would be needed:
    In buttons.c, change:
    Code:
    			if (count >= 3) {
    				nvram_set("restore_defaults", "1");
    				nvram_commit();
    				sync();
    				reboot(RB_AUTOBOOT);
    			}
    			else {
    				led(LED_DIAG, 1);
    				set_action(ACT_REBOOT);
    				kill(1, SIGTERM);
    			}
    to
    Code:
    			if (count >= 3) {
    				nvram_set("restore_defaults", "1");
    				nvram_commit();
    				sync();
    				reboot(RB_AUTOBOOT);
    			}
    			else if (count <= 1) {
    				nvram_set("rrules_radio", "-1");
    				eval("radio", "toggle");
    				continue;
    			}
    			else {
    				led(LED_DIAG, 1);
    				set_action(ACT_REBOOT);
    				kill(1, SIGTERM);
    			}
    This would make it so that one second or less would toggle radio, between one and three seconds would reboot, and greater than three seconds would clear nvram and reboot.

    Now for the disclaimer. This was straight from my brain to this post, so I haven't tried running or even compiling this. Do so at your own risk.
     

Share This Page