Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

LEDE/OpenWRT controls gpio-led

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Led configuration

The Led configuration is located in system uci subsystem, and written in the / etc/config/system file.

Leds section

The leds section contains settings that apply to non-default leds

Default leds are usually "power connected" led, "system alive" led, leds showing ethernet port activity and leds showing wifi radio status. Their settings are defined somewhere else, see development guides)

This is an example of leds on a tp-link router with usb port.

Root@lede:/# uci show system | grep "system.led" system.led_usb=ledsystem.led_usb.name='USB'system.led_usb.sysfs='tp-link:green:usb'system.led_usb.trigger='usbdev'system.led_usb.interval='50'system.led_usb.dev='1-1 roomsystem.ledroomwlan.nameroomWLANroomsystem.ledroomwlan.sysfsroomsystemtplinkwlansystem.ledroomwlan.ledroomphy0tptroomroot@ Lede:/# cat / etc/config/systemconfig led 'led_usb' option name' USB' option sysfs' tp-link:green:usb' option trigger 'usbdev' option interval' 50' option dev' 1-1'config led 'led_wlan' option name' WLAN' option sysfs' tp-link:green:wlan' option trigger 'phy0tpt'How to add Leds to this section

All LEDs are represented by entries in the sys filesystem. You can check which LEDs are available in the / sys/class/leds directory.

The name of an entry typically consists of the name of the hardware providing the LED (the router model), the color of the LED, and it's designation (usually the label on the case).

Some LEDs can show different colors. In this case, you will find one entry per color.

Root@lede:/# ls / sys/class/leds/tp-link:green:qss tp-link:green:usbtp-link:green:system tp-link:green:wlan

The LED can be controlled by various events in the system, which is selected by the trigger option. Depending on the trigger, additional options must be specified. First of all, you need to know which triggers are available for a led, to do that simply look at the trigger file of that led. Example:

Root@lede:/# cat / sys/class/leds/tp-link:green:qss/trigger [none] switch0 timer default-on netdev usbdev phy0rx phy0tx phy0assoc phy0radio phy0tpt

If we wanted to (temporarily) assign a default-on trigger to the led, we would write

Root@lede: echo "default-on" > / sys/class/leds/tp-link:green:qss/trigger

You can confirm that you changed this by using cat again, you will see it has changed and the selected trigger is highlighted.

Root@lede:/# cat / sys/class/leds/tp-link:green:qss/triggernone switch0 timer [default-on] netdev usbdev phy0rx phy0tx phy0assoc phy0radio phy0tpt

Now, this change will be lost on reboot, if you want to make a permanent change, you need to add the trigger in uci configuration.

If you have already a section in uci configuration that shows the led you want to set up, you just need to add the trigger.

For example, if you want change the trigger assigned to tp-link:green:wlan into "default-on" and you already have a block of options for it like this when you write uci show system | grep "system.led" (you can have more or less, it may also not have a trigger already assigned).

System.led_wlan=ledsystem.led_wlan.name='WLAN'system.led_wlan.sysfs='tp-link:green:wlan'system.led_wlan.trigger='phy0tpt'

Then you can write

Uci set system.led_wlan.trigger='default-on'uci commit

If you don't have any configuration for it, you can add it and the trigger by editing the following example text (that sets wps led as "default-on" and then copy-pasting it whole in the terminal window.

Rule_name=$ (uci add system led_wps) uci batch

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report