I'have 3 old TL-WR740n v4.20 and I wanted to use the led of the router as relays outputs.
First I've set it to wireles client, and went to System/Leds and renamed some unused leds to out1 to out6. Also set the led trigger to none
after that I found out that in SSH i can get some led status by # uci get system.out1.default
and i can turn a led on or off with (1 to on, 0 to off)
# uci set system.out1.default=1
# uci commit
# /etc/init.d/led restart
felling happy I started to create the web ui to control the leds
very simple:
six forms
each one get one checkbox with a onChange="this.form.submit()"
so here begins my problem: i couldn't make the script work. I've made a lot of scripts to the formAction but none worked.
then I gave up and tried crelay... unsucessfully. It is almost what I need, but is focused in Usb Relays boards.
I want to use my routers leds, some old relays and transistors that I have at home.
my device doesn't have a lot of free space, only 68kb. (it is trashy, but not useless)
Now I'm back in the beggining with almost nothing.
Could somebody help me with this? if you do only one I can do the others.
what I'm trying to do is:
get the led status, dispay the checkbox accordingly, and toggle the led. without any packages besides the ones already compiled. uHttpd, luci and etc
The "normal" procedure for controlling LEDs is not by changing the default configuration using "uci". All controllable LEDs should be accessible at "/sys/class/leds"; you can just read and write from those "files".
If you share your code others can have a look at it, and point where could be the issue.
If you are willing to enter the rabbit hole, search for these terms, and keep yourself entertained for an evening or two: HomeAssistan, Domoticz, Tasmota, ESPHome, OpenHAB, Arduino, ESP8266, ESP32, firmata, ...
In my google search i saw that everybody does this way (/sys/class/leds), but in my tests when the router reboot it always back to defaults set in the config files. I was thinking about that. if the router reboots, it returns in last state
From the list I only know 2 terms: arduino and Domoticz. I'll do my homework
I only have a static html page I tried to make it dynamic.. I did like the LuCI index.html
and called a script in /www/cgi-bin ... in what language should this script be? is it lua? everything I tryed I have failed. I've even copy/paste a Hello World and it didn't run (permissions 755)
I miss something like
Because of your resource constraints, best to have static HTML only.
LUA should also be possible to be used.
In case, you can drop LuCI completely, streamline your 18.06 (?) by removal of non-required stuff (PPP etc.), debug file system etc. and you are willing to build custom image, you might be able to install PHP.
actually... crelay supports raw gpio outputs... ( depending on your release... you may need to unload/uninstall a module or edit your dts to free up the gpio's )
Sorry, I have no expirience in using LUA on openwrt to serve and process web pages.
But I used PHP rather extensively on openwrt-devices having more resources.
However, the 4/32 might be sufficient enough for some old openwrt, which you need to use, anyway, and some streamlined PHP. Assuming, you give up LUCI, and some more.
Frankly speaking, interesting question, whether it will fit. Which version of openwrt do you use ?
OK, I will try to build a minimal image for your device, without LuCI, and some more streamlining. But having PHP. Lockdown is boring, anyway Will let you know, whether it is possible. 17.01.5 should be best, because of PHP5 (I hope).
Package removal does not release the space in flash.
Either to use imagebuilder, or, even better, build from src. Which I will do.
Should be ready tomorrow, latest.
Yes, that is expected behaviour. Bear in mind that each time you reconfigure the defaults, you are writing to your device's flash memory, which has a limited lifespan.