I have some router that are used as a repeater (wifi to ethernet)
To be able to see the signal strength without needing to log inn to web gui / winbox etc, I have made a script.
It test signal strengt on first wifi client and blinks the led to show signal strengt.
Less blink are better than many so
-30 dBm = 3 blink
-63 dBm = 6 blink
Last blink is longer to show that its at the end.
Scripts should run for ever or until you change global value runLoop to false.
But there are some bugs with it.
When I start it with a client connected it runs fine.
Stop the client and no more blink.
But turn on the client again and i do not get any blink.
IF I do run this command it will work again
:global runLoop true
: do {
: do {
: local a [/interface wireless registration-table get value-name=signal-strength 0]
: local loop ([:pick ([:pick $a 0 [:find $a "dBm"]]/10) 1]-0)
: if ([:len $a] = 0) do={
} else={
: for e from 1 to $loop do={
/system leds set [find where leds="wlan-led" ] type=off
:delay 500ms
/system leds set [find where leds="wlan-led" ] type=on
:delay 500ms
}
}
:delay 1s
/system leds set [find where leds="wlan-led" ] type=off
:delay 2s
} on-error={}
} while=($runLoop)
To run it for terminal add { } before and after script and copy it inn to the router.
Doesn’t such a script incur a lot of flash writes because every ‘/system leds set [find where leds=“wlan-led” ] type=’ command is not only controlling the LED state but is also being saved as a new configuration state that is supposed to survive reboot?
When you do led blinking that way it could wear the flash memory.
There should be some LED control command that is not part of configuration…
I think there should be a new type of LED control like type=soft or similar, where the LED is controlled by a software/script command that can turn it on or off (or maybe even send a programmed blinking sequence repeatedly) but that is not saved as part of the configuration.
So in the configuration only the type=soft is stored, and then you can do something like:
/system leds control [find where leds=“wlan-led” ] on
/system leds control [find where leds=“wlan-led” ] off
/system leds control [find where leds=“wlan-led” ] blink
/system leds control [find where leds=“wlan-led” ] pattern=“…-”
This “control” command only controls the LED from the time it has been issued in a running router (usually from a script), but would not be saved in flash.