as some devices have a dedicated button for LEDs I was thinking about adding a feature for using this buttons in OpenWRT.
Right now I see four different possible cases:
- No button
- Push button
- Toggle button
- Button + special hw function like TP-Link EC330-G5u v1
My test device is a ramips MT7621 Zyxel WSM20, I already created a script for this device but I would like to extend it till a generic solution is built.
My idea is to use
0 for shutting down the LEDs and
1 for have them on. For that I created a proof of concept with an extension in the
/etc/init.d/led script which reads this value and in case that
0 is set the script will only shut down all LEDs and then exit. (Adding a stop function with this functionality would also be an option.)
In the POC there's also an example for the push and toggle buttons included.
I see advantages in this solution for starting a generic way and case 1) with no button still could use it as "soft" button for cron jobs if the LEDs should be turned off during night as example and for case 2) could a default state in (L)uci added what status should be used after a reboot and all of the LED logic is in one place.
But I'm unsure if this solution is the right way of doing it - especially because a change in an init file could potentially brake something for many users.
Some things are open:
rc.button/lights_togglescript in git: How to deal with all the devices?
- How to read the value of a toggle button after a reboot in a generic way? (For the WSM20 I use
grep -E '^ gpio-496 .*) in hi' /sys/kernel/debug/gpio)
- Which features should also be integrated?
- Are there more cases than 1-4?
- Integration into (L)uci