By default, all the LED is controlled for its original function, therefore you must set the trigger file (/sys/class/leds/LED_NAME/trigger) to none before you can manually control a LED.
- First, we need to check what LEDs are available
ls -1 /sys/class/leds/ - Example of output from my GL.iNet router:
ath9k-phy0
gl-connect:green:lan
gl-connect:red:wlan - You may want to know the LED trigger name before go to the next step, this is not require but is necessary if you want to set the LED to go back to its default function later.
cat /sys/class/leds/gl-connect:red:wlan/trigger - Example below shows the trigger name is phy0tpt (with square bracket)
none switch0 timer default-on netdev phy0rx phy0tx phy0assoc phy0radio [phy0tpt] - Suppose we want to control the gl-connect:red:wlan LED manually, we can use the following command to disable its default function.
echo none> /sys/class/leds/gl-connect:red:wlan/trigger - The LED can be turned on and off using the 'brightness' file, set brightness to 0 will turn off the LED and any value greater than 0 will turn on the LED.
echo 1 > /sys/class/leds/gl-connect:red:wlan/brightness #turn on LED echo 0 > /sys/class/leds/gl-connect:red:wlan/brightness #turn off LED - You may want the LED to go back to its default function.
echo phy0tpt> /sys/class/leds/gl-connect:red:wlan/trigger
Set the trigger file to none after router boots up
Save the following code to /etc/init.d/manualControlLED, this will disable the trigger for gl-connect:red:wlan LED.
#!/bin/sh /etc/rc.common START=99 STOP=15 start() { echo none> /sys/class/leds/gl-connect:red:wlan/trigger } stop() { echo phy0tpt> /sys/class/leds/gl-connect:red:wlan/trigger }
- Set file permission to 0755
chmod 0755 /etc/init.d/manualControlLED - Disable trigger for LED, you can now control the LED manually.
/etc/init.d/manualControlLED start - Go back to its default function.
/etc/init.d/manualControlLED stop - Enable service autostart
/etc/init.d/manualControlLED enable - Disable service autostart
/etc/init.d/manualControlLED disable