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

Stealth Mode (Timer function) RT-N66

Discussion in 'Tomato Firmware' started by kthaddock, Nov 16, 2012.

  1. kthaddock

    kthaddock Network Guru Member

    Turn your lan leds off/on.
    All credits to RMerlin.
    https://github.com/RMerl/asuswrt-merlin/issues/138

    services-start:
    Code:
    #!/bin/sh
    cru a lightsoff 0 18 * * * "/jffs/scripts/ledsoff.sh"
    cru a lightson 0 6 * * * "/jffs/scripts/ledson.sh"
    ledsoff.sh:
    Code:
    #!/bin/sh
    nvram set led_disable=1
    nvram commit
    service restart_leds
    ledson.sh:
    Code:
    #!/bin/sh
    nvram set led_disable=0
    nvram commit
    service restart_leds
     
  2. kthaddock

    kthaddock Network Guru Member

    Then I realize that maby only work in Asus firmware, can't test that. ;)
     
  3. RMerlin

    RMerlin Network Guru Member

    Yes, I had to add specific code for this to work. However you can manually replicate some of this on Tomato through either the "wl" command or "et" command. See boardapi.c under led_control() for how to use these commands to disable either wireless or ethernet leds:

    https://github.com/RMerl/asuswrt-merlin/blob/master/release/src/router/shared/boardapi.c

    Other LEDs can be controled through gpio, depending on which router you have.

    BTW I see you have an RT-N16. Could you confirm that the wl and et commands used in led_control() do work on that router?

    (EDIT: fixed Git link)
     
  4. tvlz

    tvlz Addicted to LI Member

    This works on RT-N16, paste in system commands
    Code:
    turn off all leds:
    gpio enable 1
    eval "wl" "-i" "eth1" "leddc" "1"
    eval "et" "robowr" "0x00" "0x18" "0x1e0"
    eval "et" "robowr" "0x00" "0x1a" "0x1e0"
     
    turn on all leds:
    gpio disable 1
    eval "wl" "-i" "eth1" "leddc" "0"
    eval "et" "robowr" "0x00" "0x18" "0x1ff"
    eval "et" "robowr" "0x00" "0x1a" "0x1ff"
     
  5. Elfew

    Elfew Addicted to LI Member

    Is this working on tomato?

    ok, I tested - wan and power leds are off but everything flashing
     
  6. koitsu

    koitsu Network Guru Member

    Helpful comment in passing: do not get in the habit of using eval. That's a very very bad habit. Stop that before it results in security problems for you sometime in the future (especially with regards to scripts). The same is just fine, and with removal of potential security concerns + excessive quoting:

    Code:
    turn off all leds:
     
    gpio enable 1
    wl -i eth1 leddc 1
    et robowr 0x00 0x18 0x1e0
    et robowr 0x00 0x1a 0x1e0
     
    turn on all leds:
     
    gpio disable 1
    wl -i eth1 leddc 0
    et robowr 0x00 0x18 0x1ff
    et robowr 0x00 0x1a 0x1ff
    
     
  7. tvlz

    tvlz Addicted to LI Member

    Thanks for the info koitsu,
    I just grabbed from Rmerlin's code to try it, to bad I can't edit my post:(

    Elfew
    try turn them on first then off?
     
    koitsu likes this.
  8. Elfew

    Elfew Addicted to LI Member

    ONLY power, wifi and wan led are off... everything else (lan1,2,3,4) are blinking
     
  9. kthaddock

    kthaddock Network Guru Member

    Where do you put it when you test ? Tools => commands => execute ???

    OFF
    ON
     
  10. Elfew

    Elfew Addicted to LI Member

    yes...

    btw - can I use this in sheduler?
     
  11. kthaddock

    kthaddock Network Guru Member

    Do a reboot and test again
     
  12. Elfew

    Elfew Addicted to LI Member

    OK, I will test it. Can I use it in sheduler? OFF from 9PM to 6AM after that ON
     
  13. kthaddock

    kthaddock Network Guru Member

    Yes, ex off 20:00 on 06:00 (off 08:00 pm on 06:00 am)
    Working fine here
     
  14. Elfew

    Elfew Addicted to LI Member

    OK, now it works correctly after reboot...

    do you recommend any other script? :D
     
  15. RMerlin

    RMerlin Network Guru Member

    The two et commands have to be run in sequence to turn off the LAN LEDs.

    Regarding eval: The firmware is filled with eval() calls left and right. Not sure this warning applies to the C call like it does to shell scripting. For instance all those eval() calls are using hardcoded parameters, there's no user-entered input.

    But yeah, there is no reason to use eval in your script.
     
  16. jjw7mc

    jjw7mc Serious Server Member

    Hello,

    I just tried this on my Asus RT-N66U. The power, 5Ghz and USB LED's remain ON, all other LED's turns OFF. I tested by adding the below as a shedule task in Administration-->Scheduler-->Custom 1

    I've rebooted the router but still same results. Any ideas why its not working?

    Code:
    gpio enable 1
    wl -i eth1 leddc 1
    et robowr 0x00 0x18 0x1e0
    et robowr 0x00 0x1a 0x1e0
    
     
  17. RMerlin

    RMerlin Network Guru Member

    add another command that refers to eth2 instead of eth1 to turn off the 5 GHz led.

    USB led will probably require firmware-level support. You could turn it off through gpio, but any USB action might turn it back on unless the firmware is modified to handle it.
     
  18. jjw7mc

    jjw7mc Serious Server Member

    Thanks RMerlin, I added another command for eth2, it works now, the 5GHz led is off. Is there anything I could do about the Power led?
     
  19. Elfew

    Elfew Addicted to LI Member

    On asus rt-16n it works great in sheduler (leds are turned off during the night)

    try merlins advise
     
  20. RMerlin

    RMerlin Network Guru Member

    Power LED GPIO on the RT-N66U is 4106. No idea what's the syntax to write to a gpio address under Tomato.
     
  21. FireWire

    FireWire Serious Server Member

    This works for Asus RT-N66U under Shibby´s version of Tomato, I have tested this and have it in scheduler to turn the led lights off during night time and turned on in the morning to have the lights on during daytime.

    DISABLE LED:
    *****************
    et robowr 0x00 0x18 0x1e0
    et robowr 0x00 0x1a 0x1e0
    wl -i eth1 leddc 1
    wl -i eth2 leddc 1
    gpio enable 12
    gpio enable 15

    ENABLE LED:
    *****************
    et robowr 0x00 0x18 0x1ff
    et robowr 0x00 0x1a 0x1ff
    wl -i eth1 leddc 0
    wl -i eth2 leddc 0
    gpio disable 12
    gpio disable 15

    Explanation of the settings:
    ******************************
    WAN ON/OFF: et robowr 0x00 0x18 0x1ff(ON)/et robowr 0x00 0x18 0x1e0(OFF)
    LAN ON/OFF: et robowr 0x00 0x1a 0x1ff(ON)/et robowr 0x00 0x1a 0x1e0(OFF)
    WIRELESS 2.4GHZ(ON/OFF): wl -i eth1 leddc 0(ON)/wl -i eth1 leddc 1(OFF)
    WIRELESS 5GHZ(ON/OFF):wl -i eth2 leddc 0(ON)/wl -i eth2 leddc 1(OFF)
    POWERLED(ON/OFF): gpio disable 12(ON)/gpio enable 12(OFF)
    USB LED(ON/OFF): gpio disable 15(ON)/gpio enable 15(OFF)

    Hopes this helps someone, who like to turn on/off the led lights. Don´t know if this information is available in some other thread, but could not find any other threads regarding turning on/off the led lights, when I searched the forum.

    //FireWire
     
  22. kthaddock

    kthaddock Network Guru Member

    Have you tested this on tex 107 builds?
     
  23. FireWire

    FireWire Serious Server Member

    No, didn´t know about that command. It worked nicely. Thanks kthaddock =).
     
  24. kthaddock

    kthaddock Network Guru Member

    Yepp. It's nice :)
     
  25. shibby20

    shibby20 Network Guru Member

    this is why you should read changelog before flash new tomato version ;)
     
    koitsu likes this.
  26. FireWire

    FireWire Serious Server Member

    I always read the changelog, but didn´t see this command specified. I saw something about "- StealthMode v0.3 (fixed turn on/off leds on RT-N16, add „leds guardian” to cru) (thx Monter)", but I can´t find anywhere how this feature is enabled/disabled. I am not very skilled regarding routers and networks etc, so it´s not that obv to me. Is there a tutorial or FAQ somewhere with commands that can be used in your firmware? Would be really nice with basic 'How to' for us less advanced users.
    But thanks for your work shibby with this firmware, I really appreciate your effort =).

    //FireWire
     
  27. Bird333

    Bird333 Network Guru Member

    Stealthmode is cool. Just wanted to report that USB activity does turn the light back on.
     
  28. shibby20

    shibby20 Network Guru Member

    And it will be. Some features can turn on leds like power or usb. Stealthmode has a guardian and every 5mins all leds are turn off . This is only one logical solution that i have found.

    Best regards.
     
  29. RMerlin

    RMerlin Network Guru Member

    Have you checked if Tomato has a usbled process? If so, you should be able to simply terminate that process when entering stealth mode, and re-enable it when stealth mode is being disabled. That's how I did it here.
     
  30. kthaddock

    kthaddock Network Guru Member

  31. RMerlin

    RMerlin Network Guru Member

    Ain't so simple as that... Asus uses different formulas in different places. Their webui code uses the code I posted. The rc daemon uses the code that BS has used. So who knows which is right...
     
  32. uboot

    uboot Serious Server Member

    Led reporting usb activities is not turned off (under Shibby AIO 108). :(
    I read it's a known issue.
     
  33. uboot

    uboot Serious Server Member

    Why not use poll command to check led changes or directly rewrite the script in C to get more control over gpio interface?
     
    Last edited: Aug 23, 2013
  34. RMerlin

    RMerlin Network Guru Member

    Or simply interface with the rc code that turns LEDs on - if stealth mode is enabled, silently ignore a led_control() call trying to turn a LED back on. That's how I implemented it on my end.

    Polling is evil IMHO.
     
    uboot likes this.
  35. Elfew

    Elfew Addicted to LI Member

    I use a command in scheduler, it works
     
  36. Jau-Ling Chou

    Jau-Ling Chou Serious Server Member

    my n66u sits next to my tv, and it is a bit annoying the usb LED turns on and off (i'm running shibby 114). until this is solved in code, the easiest workaround really is just a little piece of electrical tape to cover it up ;)
     
  37. trezor

    trezor Reformed Router Member

    If you want to turn off the light everytime after the reboot you can put the script with the sleep command at the beggining.

    without sleep command the router did not turn the lights immediately after the reboot. Now it will after the 5 minutes. You can put even shorter time, it is up to you.

    sleep 300
    gpio enable 1
    wl -i eth1 leddc 1
    et robowr 0x00 0x18 0x1e0
    et robowr 0x00 0x1a 0x1e0
     
  38. kthaddock

    kthaddock Network Guru Member

    stealthMode Sunset v0.10 by Monter
    Usage: stealthMode {on|off|sun <city_code>|sun_off|sch_on <H> <M>|sch_off <H> <M>|sch_clear|clear_all}

    [Standard mode]
    on | off - enable or disable steathMode in real time

    [Sunset mode]
    sun <city_code> - will daily get the sunrise and sunset times of a specific
    location automatically and activate Sunset mode
    To be able to determine your <city_code> you need to first
    go to http://weather.yahoo.com/ and look up your location
    The last NUMBERS in the URL will be your <city_code>
    Example: "stealthMode sun 514048" if you live in Poznan/Poland ;)
    This feature requires a working Internet connection
    sun_off - fully deactivate Sunset mode

    [Scheduled mode]
    sch_on <H> <M> - set the hour and minutes of the scheduled enable/disable
    sch_off <H> <M> stealthMode in Standard mode and adding jobs to the Crontab
    Hour and minute time must be a numbers without any additional
    characters, where hour is a mandatory parameter, while not
    specifying an minute will assign a default 00 value
    These options add just the right job for Crontab, nothing more
    sch_clear - removes tasks from Crontab for scheduled enable/disable
    stealthMode function set by sch_on and sch_off switches

    [Repair / debug]
    clear_all - removes all jobs from Crontab and completely disables all
    available stealthMode modes
     
    maple.chick and ShinichiYao like this.
  39. gffmac

    gffmac Serious Server Member

    Getting errors when setting Sunset mode:

    root@RT-N66U:/tmp/home/root# stealthMode sun 27613131
    stealthMode: Sunset Enabled
    stealthMode: Scheduler Tasks Deleted
    wget: server returned error: HTTP/1.1 401 Unauthorized
    stealthMode: Weather sunset time error!

    Anyone know why? Is yahoo blocking it??
     
  40. koitsu

    koitsu Network Guru Member

    It means the HTTP/HTTPS API endpoint the script is hitting is requiring user/password authentication. Odds are Yahoo changed something (possibly the URL redirects somewhere else, possibly the deprecated the API). The maintainer of this script gets to reverse-engineer what Yahoo has done to make it work again. I've already ranted about the ridiculousness of a script like this doing any kind of network access at all (the whole "at sundown" premise is so silly) -- case in point. :p
     
  41. Monter

    Monter New Member Member

    Weather service from which the data are retrieved (sunrise and sunset) in short time changed twice the rules of access to the API. First, at yahooapis address operating for several years included a mandatory OAuth authorization, and later in the next week stopped working alternative xml source.

    In late April, I introduced the necessary changes to applications and two days ago I released a new version designed for MIPSEL routers, which is available at my blog.
     

Share This Page