Using the LED tab to control the USB power is not very elegant
However, you are right, this may be what is the closest to what we want to do, so I will start from there.
Actually, the button tab is included into luci-admin-full, but it is severely broken...
The CBI LuCI <=> uci config binding file is "/modules/admin-full/luasrc/model/cbi/admin_system/buttons.c" in the build_dir, and placed into "/usr/lib/lua/luci/model/cbi/admin_system" on the router, but it lacks the mandatory final "return m" statement!
Then, it should be called by the parent index() function in the "/modules/admin-full/luasrc/controller/admin/system.lua" controller, but it is not...
Here is the patch file:
diff -Naur luci-0.11+svn9413.orig/modules/admin-full/luasrc/controller/admin/system.lua luci-0.11+svn9413/modules/admin-full/luasrc/controller/admin/system.lua
--- luci-0.11+svn9413.orig/modules/admin-full/luasrc/controller/admin/system.lua 2012-08-08 12:11:00.000000000 +0200
+++ luci-0.11+svn9413/modules/admin-full/luasrc/controller/admin/system.lua 2012-11-02 18:34:39.000000000 +0100
@@ -40,6 +40,8 @@
entry({"admin", "system", "leds"}, cbi("admin_system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
end
+ entry({"admin", "system", "buttons"}, cbi("admin_system/buttons"), _("Buttons"), 65)
+
entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70)
entry({"admin", "system", "flashops", "backupfiles"}, form("admin_system/backupfiles"))
diff -Naur luci-0.11+svn9413.orig/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua luci-0.11+svn9413/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua
--- luci-0.11+svn9413.orig/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua 2009-11-01 02:37:03.000000000 +0100
+++ luci-0.11+svn9413/modules/admin-full/luasrc/model/cbi/admin_system/buttons.lua 2012-11-02 18:35:13.000000000 +0100
@@ -36,3 +36,4 @@
max = s:option(Value, "max", translate("Maximum hold time"))
max.rmempty = true
+return m
Here is the result using the beautiful "Bootstrap" theme:
What this page basically do is to modify the corresponding uci config entries in /etc/config/system like this:
config button
option button 'reset'
option action 'released'
option handler 'logger reset button pressed'
option min 0
option max 3
In order to do something actually useful, you must follow the tutorial in the wiki about buttons:
http://wiki.openwrt.org/doc/howto/hardware.button
In this tutorial:
the "button" events are enabled in the "/etc/hotplug2.rules" config file
a button handler script is created. In the original example, the first "#!/bin/sh" dashbang line was missing, resulting in nothing happening at all!
Eventually now, when I press the reset button on my TL-WR703N router for less than 3 s, I get a message in the log "reset button pressed", that I can follow using "logread -f"