Doing funny things with the onboard leds of the GL-AR150 :-)

While finding a way to let the onboard leds of the GL-AR150 (firmware 2.13 CC) return to their configured state after using the leds in a script I discovered you can do a lot of funny things with them. The posibilities are listed below the section “Leds” on this page: System configuration [Old OpenWrt Wiki]

I decided to test the morse-function of the leds.
It works, but you have to pay some attention to things to get it to work.

I used this OpenWRT forumpost as a base: OpenWrt Forum Archive

You can install the needed package in the following ways:

  • From the console / SSH session: opkg install kmod-ledtrig-morse
  • From LuCI: Go to Menu > System > Software. Fill in "kmod-ledtrig-morse" at the field "Download and install package:" and click on "OK".
  • From GLi webinterface: Go to "App repo" pane. Fill in "libusb-compat" at the search field and click on "Search". Click on "install " in front of "kmod-ledtrig-morse".
Then came the tricky part: I wasn't able to proceed with the instructions due errors. I needed to reboot the GL-AR150. You can remove the power and then reconnect the power. Another way is to type "reboot" within the console / SSH session and then press enter.

Then I proceeded with the steps as mentioned on the OpenWRT forum. First I need to add the new trigger “morse” to all the available onboard leds:

echo morse > /sys/class/leds/gl_ar150\:wlan/trigger
echo morse > /sys/class/leds/gl_ar150\:lan/trigger
echo morse > /sys/class/leds/gl_ar150\:wan/trigger

Then you need to save and apply the trigger for the led you want to use to “morse”. I want to do that on the SSH session, but I can’t find a way how to that. So I went to the LuCI webinterface: Menu > System > LED configuration
Where the “LED Name” is set to “gl_ar150:wlan” I selected a few lines below that line “morse” as “trigger”.
Then I clicked “Save & apply” at the bottom.
Now the red wlan led is ready to recieve morse commands.

For example, you could show the morse for “SOS” with the following command at the console / SSH session:
echo "SOS" > /sys/class/leds/gl_ar150:wlan/message

And then you have to press enter. Shortly after that you will see the wlan led flashing the morse-code for “SOS”. :wink:

Finally, my question: does anyone have an idea how to change and apply the trigger for each led within the console or SSH session?

1 Like

Alright… After reading some documentation about UCI on The UCI System [Old OpenWrt Wiki] I found out it my self.

First I had to determine which array index of leds I needed to use.
You can export the UCI settings to the console / SSH session by typing

uci export system

 

This is my led configuration currently:

config led 'led_wlan'
option default '0'
option name 'LAN'
option trigger 'netdev'
option dev 'eth1'
option mode 'link tx rx'
option sysfs 'gl_ar150:lan'

config led
option default '0'
option name 'WLAN'
option sysfs 'gl_ar150:wlan'
option dev 'wlan0'
option mode 'link tx rx'
option trigger 'morse'

config led
option name 'WAN'
option sysfs 'gl_ar150:wan'
option default '0'
option dev 'eth0'
option mode 'link tx rx'
option trigger 'netdev'

 

When accessing the leds in an array it’s importent to know an array starts with an index-number of 0 (zero), so my “LAN” has index 0, “WLAN” has index 1 and “WAN” has index 2.

 

To apply modified led settings you can restart the led-deamon with:

/etc/init.d/led start

 

So when you want to use the morse-code from within console / SSH / shell-script with my own led-configuration you can use:

uci set system.@led[1].trigger=morse
uci commit system
/etc/init.d/led start
echo "SOS" > /sys/class/leds/gl_ar150:wlan/message

 

Scritly the line “uci commit system” isn’t neccesarely to perform (it worked without performing the command at my configuration) but is common sense with most uci settings, so it’s better to perform that command.

The @-sign tells uci that “led” shows up more then 1 time within the configuration and you want to access the array of the led-configurations. The [1] tells UCI to use the second led-configuration.

To reset my WLAN led back to blinking on RX and TX I only needed to set the trigger back to “netdev” and apple the new led-settings:

uci set system.@led[1].trigger=netdev
uci commit system
/etc/init.d/led start

I want to fetch the old trigger-value within a bash script to be able to revert the trigger-value back to its original when the bash scripts end.

I am able to fetch the configuration line I need with:

uci show system.@led[1].trigger

 

The output will be:

system.cfg068bba.trigger='netdev'

 

But I only need “netdev” from this line and it should be stored in a variable within the bash script.
Does anyone know how to fetch the “netdev” from that line and place it into a variable?

Hey that’s a nice project!

here you are

uci get system.@led[1].trigger

It is easier that you name each led in the uci config, .e.g. the bold text below.

Then you can use

uci get system.led_wlan.trigger

to get the value.

config led 'led_wlan'
option default '0'
option name 'LAN'
option trigger 'netdev'
option dev 'eth1'
option mode 'link tx rx'
option sysfs 'gl_ar150:lan'

1 Like

Thank you for the hint alzhao! That makes things a little easier. :wink:
Also thanks for the answer on my question. It will help me a lot. :slight_smile: