Wifitoggle: configuring LED


I successfully installed the package wifitoggle and made the hardware button marked "wifi" work: I can now turn wifi on and off using this button. No problem there. :slight_smile:

What puzzles me is the corresponding LED: it does not light up before the first mobile device is connected to the router. As long as there's no connection, the LED will stay off, although the radio device is active and the network will be discovered by mobile devices.

Can I change this behaviour so that the LED lights up as soon as I push the button to turn wifi on?

Thanks in advance!

please post output command:

uci show wifitoggle

I assume you have done what this guide tells you:

have you already tried to change the following parameter

uci set wifitoggle.@wifitoggle[0].led_enable_trigger='default-on'
uci commit

see also this guide:

Personally I preferred a specific configuration on my routers (fritz box 4040) based on hotplug buttons and customized scripts that activate the wifi and LEDs I want.


Sorry for the delay: busy days. :frowning:

Certainly, here you are:


Yes, I found articles about that parameter before.

All settings to the status of this LED (and others) have been made via GUI / LUCI. Apparently, LUCI puts the necessary parameters into two different files. In /etc/config/system there's this section :

config led 'led_wlan'
        option name 'WLAN'
        option sysfs 'green:wlan'
        option trigger 'netdev'
        list mode 'link'
        list mode 'tx'
        list mode 'rx'
        option dev 'wlan1'

And then there's also the file /etc/wifitoggle, with these lines — and olny these lines — in it:

config wifitoggle
        option button 'wlan'
        option persistent '0'
        option timer '600'
        option led_enable_delayon '500'
        option led_enable_delayoff '500'
        option led_disable_default '1'
        option led_enable_trigger 'default-on'

And I think I know why the LED is switched on after a certain delay, now that I see this line in /etc/config/system:

    option dev 'wlan1'

I defined two wifi networks, one on 2GHz and one on 5GHz, because some of my devices are capable of 2GHz only. It seens, the LED can react to one wifi connection only. So, I think the delay is due to the fact that the 2GHz devices simply take a few seconds, before the first one logs into the network, causing the LED to be triggered.

I guess if I changed "wlan1" into "wlan0", it would just mean that the system will wait for the first 5GHz device to connect, before it will turn on the LED, no matter how many 5GHz connections have already been established.

So, the big question is: how can I tell the system to trigger the LED, when the button is pressed and wifi is activated, regardless how many devices are connected on any network? Judging from the description of

option trigger 'netdev'

it should already be configured the way I want it to be. Or am I wrong completely?

hoping to have understood that you will use a firtzbox 4040 and that you want all the LEDs off and only one LED that shows you if the wifi is active

I can advise you to create two scripts (/root/wifi_up, /root/wifi_off) and assign the buttons (/root/switch_wifi) to the functionality of activating/deactivating the wifi...

This configuration that I post activates and deactivates the 2.4GHz and 5GHz WiFi by pressing the WLAN button on the Fritzbox 4040
the default LED configuration is off and the scripts activate the "/sys/class/leds/green:wlan" LED by first removing the wifitoggle package, avoiding depending on the latter and preventing possible disturbances between this configuration and your current one ...

cat /etc/hotplug.d/button/00-button

source /lib/functions.sh
do_button () {
    local button
    local action
    local handler
    local min
    local max
    config_get button "${1}" button
    config_get action "${1}" action
    config_get handler "${1}" handler
    config_get min "${1}" min
    config_get max "${1}" max
    [ "${ACTION}" = "${action}" -a "${BUTTON}" = "${button}" -a -n "${handler}" ] && {
        [ -z "${min}" -o -z "${max}" ] && eval ${handler}
        [ -n "${min}" -a -n "${max}" ] && {
            [ "${min}" -le "${SEEN}" -a "${max}" -ge "${SEEN}" ] && eval ${handler}
config_load system
config_foreach do_button button

cat /root/wifi_up

uci set wireless.radio0.disabled='0'
uci set wireless.radio1.disabled='0'
echo "1" > /sys/class/leds/green:wlan/brightness
wifi up >/dev/null 2>&1

cat /root/wifi_off

wifi down >/dev/null 2>&1
echo "0" > /sys/class/leds/green:wlan/brightness
uci set wireless.radio0.disabled='1'
uci set wireless.radio1.disabled='1'
wifi reload >/dev/null 2>&1

cat /root/switch_wifi

logger "exec: /root/switch_wifi"
WIFI=$(wifi status | grep "\"up\": false" | wc -l)
if [ ${WIFI} = "2" ]; then

cat /etc/config/system (only parts relating to LEDs and BUTTONs)

config led 'led_wlan'
        option name 'WLAN'
        option sysfs 'green:wlan'
        option trigger 'none'
        option default '0'

config led 'led_wan'
        option name 'WAN'
        option sysfs 'green:wan'
        option trigger 'none'
        option default '0'

config led 'led_lan'
        option name 'LAN'
        option sysfs 'green:lan'
        option trigger 'none'
        option default '0'

config led
        option name 'INFO'
        option sysfs 'amber:info'
        option trigger 'none'
        option default '0'

config led
        option name 'POWER'
        option sysfs 'green:power'
        option trigger 'none'
        option default '0'

config button
        option action 'released'
        option min '0'
        option max '3'
        option button 'rfkill'
        option handler 'logger "button WLAN push 0-3s; exec /root/switch_wifi"; /root/switch_wifi'

config button
        option action 'released'
        option min '30'
        option max '100'
        option button 'rfkill'
        option handler 'logger "button WLAN push 30-100s"'

config button
        option button 'wps'
        option action 'released'
        option min '0'
        option max '3'
        option handler 'logger "button WPS push 0-3s"'

config button
        option button 'wps'
        option action 'released'
        option min '30'
        option max '100'
        option handler 'logger "button WPS push 30-100s"'

the default wifi configuration is also off on both radio0 and radio1
(at least that's what I wanted if I don't press the start button wifi is not active)

Make sure you have something similar in your file:

cat /etc/config/wireless

config wifi-device 'radio0'
        option disabled '1'

config wifi-device 'radio1'
        option disabled '1'

and this at startup in case you want to turn off the wifi (in the event that the router has a wifi configuration to activate when it starts):

cat /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

if [ -x /root/wifi_off ]; then

exit 0

No, this is not quite what I meant. Sorry, but there has been a misunderstanding.

All LED on my fb4040 are working fine and each LED is indicating what they are supposed to indicate and what I want them to indicate: LAN, WAN, power, info. The wifi LED is also working, indicating when the wifi device (the radio chip) is active.

The only thing that's a bit irritating to me is the delay that it takes before the wifi LED is turned on after I push the wifi button. I assume that the LED is not triggered instantly by the activation of the wifi radio chip, but by the first mobile device, that establishes a connection. And that is what I would like to change: I want the LED to light up as soon as I push the button, or at least as soon as the radio chip is actually activated, which should be less than 1 second later, I guess, but not up to 10 seconds later, as it is happening now.

I might be wrong, but I believe that the option

option trigger 'netdev'

should do exactly what it sounds like: trigger the LED when the radio chip (the net device) is powered and any wifi network is activated.

If my assumption is wrong there, please tell me. If I am right though, I think this could be a bug. Or does the wifi chip really take that long to activate, is it that slow?

however you said that it takes 10 seconds to activate the wifi, it doesn't seem bad to me

the wifi activation time depends above all on which channel you have chosen, whether DSA or not,
and from possible congestion of the wifi channels by nearby routers


the reference document regarding the reference "trigger" are these:

However, the scripts I sent you can be configured by you with your specific needs, just modify the values:

cat /sys/class/leds/green:wlan/trigger
[none] timer heartbeat default-on netdev phy0rx phy0tx phy0assoc phy0radio phy0tpt phy1rx phy1tx phy1assoc phy1radio phy1tpt

cat /sys/class/leds/green:wlan/brightness

the main question to solve/analyze your problem/situation and how you want the LED to be managed, I'll give some examples:

an LED always on (regardless of whether or not there are clients connected to the wifi)
echo "default-on" > /sys/class/leds/green:wlan/trigger

or an LED lit for a specific time (regardless of whether there are clients connected to the WiFi or not)
echo "timer" > /sys/class/leds/green:wlan/trigger
echo "500" > /sys/class/leds/green:wlan/delay_on
echo "500" > /sys/class/leds/green:wlan/delay_off

or a lit LED that only shows when there is network activity (here it depends on whether there is network activity or not)
echo "netdev" > /sys/class/leds/green:wlan/trigger

So I was totally wrong after all. Shame on me, then! I will try to adapt your scripts and see where it leads me. Thanks a lot for your patience!

1 Like