base-files: uci-defaults-new, config_generate: support for gpio leds
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 26 Nov 2015 13:53:06 +0000 (13:53 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 26 Nov 2015 13:53:06 +0000 (13:53 +0000)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 47660

package/base-files/files/bin/config_generate
package/base-files/files/lib/functions/uci-defaults-new.sh

index a0ff53a72c5ca04dab23711981186124ba3e7ed1..b6675f12ce3fb1d0707cfb579e00ccab3dba38d6 100755 (executable)
@@ -305,6 +305,16 @@ generate_led() {
        EOF
 
        case "$type" in
+               gpio)
+                       local gpio inverted
+                       json_get_vars gpio inverted
+                       uci -q batch <<-EOF
+                               set system.$cfg.trigger='gpio'
+                               set system.$cfg.gpio='$gpio'
+                               set system.$cfg.inverted='$inverted'
+                       EOF
+               ;;
+
                netdev)
                        local device
                        json_get_vars device
index 2ea0742e1e23156471a18f92169f8019776e6ce3..e79ec99f531ebe8fc7d76c561e468f7afb651737 100755 (executable)
@@ -321,6 +321,27 @@ ucidef_set_led_default() {
        json_select ..
 }
 
+ucidef_set_led_gpio() {
+       local cfg="led_$1"
+       local name="$2"
+       local sysfs="$3"
+       local gpio="$4"
+       local inverted="$5"
+
+       json_select_object led
+
+       json_select_object "$1"
+       json_add_string type gpio
+       json_add_string name "$name"
+       json_add_string sysfs "$sysfs"
+       json_add_string trigger "$trigger"
+       json_add_int gpio "$gpio"
+       json_add_boolean inverted "$inverted"
+       json_select ..
+
+       json_select ..
+}
+
 ucidef_set_led_rssi() {
        local cfg="led_$1"
        local name="$2"