[solved] Night LED timer for wifi router for OpenWrt

suppose is a error ..

correct is:

echo 1 > /sys/class/leds/green:power/brightness

or:

echo "default-on" > /sys/class/leds/green:power/trigger 

documentation:
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-led
https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-led-trigger-netdev

ps: I moved this request to installation and use Openwrt, because unless you want to create a lighting package for managing LEDs it's not a real additional feature

2 Likes

Thanks, but I am talking about something like inverted default LED state. Like if I want an LED to blink, I want to make it blink in a negative state or a positive state, which can't be done through brightness file of LED which just permanently turns on or shuts off LED which I don't want to happen.

Blinking postively means default state without activity is ON (1) for LED and during activity it gets OFF (0) and then ON (1) when no activity, and this oscillation continues.

Blinking negatively means default state without activity is OFF (0) for LED and during activity it gets ON (1) and then OFF (0) when no activity, and this oscillation continues.

I am talking about changing that default state as I described above.

I guess whether this is related to that ? as presented in the link https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-led provided by @ncompact :

What: /sys/class/leds//inverted
Date: January 2011
KernelVersion: 2.6.38
Contact: Richard Purdie rpurdie@rpsys.net
Description:
Invert the LED on/off state. This parameter is specific to
gpio and backlight triggers. In case of the backlight trigger,
it is useful when driving a LED which is intended to indicate
a device in a standby like state.

ps: I moved this request to installation and use Openwrt, because unless you want to create a lighting package for managing LEDs it's not a real additional feature

And how did you moved the thread to other category as I had no access to do that ?

1 Like

I am not getting this option, not even to edit the post. Are you an admin ?

And how does this occur - empty text file but still shows list of options as trigger ? Any backend process reason :

no i not a admin user

but I believe this post is not for a new feature but for changing parameters, etc

1 Like

I understand that as its rightly done. But Regular badge is achieved or granted manually by staff ?

/sys not a regular directory and files not a regular files

view:

1 Like

By activity

1 Like

Thanks, now I understand much better about what kernel can be.

do you have this kernel on your router ?
to have this functionality you will need to have a higher kernel than 2.6.38

Yes I have kernel version 5.15.137 got through uname command but no file named as inverted in any LED directories

Thanks. Now I understand

open a new thread to understand which kernel module or opkg package allows you to make the LEDs work inverted (please, since it is not a new feature you are requesting, put it between installation and Openwrt configuration)

and close this con solution at post:

1 Like

Con meaning ?

I got this somewhere in response for doing sudo update-rc.d led-control defaults after adding a new initscript in OpenWrt :

OpenWrt typically uses the procd init system, which is different from SysV init. Procd does not use the traditional runlevel system, and its configuration is often handled differently. The update-rc.d command might not be applicable in an OpenWrt environment.

So this : sudo update-rc.d led-control defaults is not required ?

When I Enable the initscript as below and refresh Web page it automatically Disable s . Why, as earlier the same format worked?

#!/bin/sh /etc/rc.common
 
START=97
 
start()
{
	ntpd -q -p openwrt.pool.ntp.org
	if [[ $(date +%H) -ge 21 || $(date +%H) -lt 3 ]]
	then
		echo none > /sys/class/leds/green:lan/trigger
		echo none > /sys/class/leds/green:wan/trigger
		echo none > /sys/class/leds/green:wlan-2/trigger
		echo none > /sys/class/leds/green:wlan-5/trigger
		echo 0 > /sys/class/leds/green:power/brightness
	else
		stop
	fi
}
stop()
{
	/etc/init.d/led start
}
enable()
{
	start
}                
disable()
{
	stop
}

Also its symlink is not getting created in /etc/rc.d/ folder even though i enabled it using service led_timer2 enable

led_timer2 is above initscript

Same issue as this:

My Initscript:

#!/bin/sh /etc/rc.common

START=97

enable()
{
	start
}
disable()
{
	stop
}
start()
{
	ntpd -q -p openwrt.pool.ntp.org
	if [[ $(date +%H) -ge 21 || $(date +%H) -lt 3 ]]
	then
		echo none > /sys/class/leds/green:lan/trigger
		echo none > /sys/class/leds/green:wan/trigger
		echo none > /sys/class/leds/green:wlan-2/trigger
		echo none > /sys/class/leds/green:wlan-5/trigger
		echo 0 > /sys/class/leds/green:power/brightness
	else
		stop
	fi
}
stop()
{
	/etc/init.d/led start
}

Fortunately, thank god, I didn't mark this thread as solved because earlier I was thinking that if initscript doesn't work then I will use Startup subsection's Local Startup tab (which controls /etc/rc.local file) to execute the LED-turn-off script file to turn off LEDs as suggested by @maurer and @elbertmai but when I used rc.local and the executed script sends LED off commands to all 5 LEDs (lan, wan, power, wlan-2, wlan-5) after reboot, only lan and wan LEDs turn off but no effect on power, wlan-2 and wlan-5 LEDs (they remain on).

When I explicitly execute the script from ssh then all LEDs turn off but not if the script gets executed after reboot automatically as defined by me in rc.local.

Neither rc.local file worked nor initscript is getting enabled permanently. Now what should I do ? Someone please guide me.

Tested multiple times but didn't work. So this thread is still unsolved. Good that I didn't close this as solved.

I have no solutions available now :disappointed_relieved:. Hoping if community can help please.
Waiting for any guidance from community
Thank you

Most likely only lan and wan are software leds and the other ones are "hardwired" to the cpu somehow.
It would help if you would "dig" through the gpl tarball of your vendor firmware to check how the implemented full led off

1 Like

Thanks for replying. I am new and not experienced yet but I don't think so because Initscript is successful in turning off all LEDs (which did not happen with startup script in local.rc) but only issue is that symlink of the Initscript fails to create in rc.d folder on tapping Enabled button. The Enabled button turns back to Disabled button on just if I refresh LUCI web UI page.

Also can you please suggest me where should I start in GPL tarball as i am just starting to understand how to interpret and manipulate linux code and environment.

Maybe there's no need to dig into the gpl tarball if it works via the rc.local - why don't you use this solution?

1 Like