base-files: support port_state LED types in board.d
authorJo-Philipp Wich <jo@mein.io>
Tue, 31 May 2016 12:35:24 +0000 (14:35 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 7 Jun 2016 22:31:09 +0000 (00:31 +0200)
Add support for handling port_state LEDs as used by ADM5120.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
package/base-files/files/bin/config_generate
package/base-files/files/lib/functions/uci-defaults.sh

index 2036ae44fe133ee60e13574b234af1122f044c92..428c6bd9dee513aa2f3c1f1d7e62c180f0f94ec8 100755 (executable)
@@ -354,6 +354,14 @@ generate_led() {
                        EOF
                ;;
 
+               portstate)
+                       local port_state
+                       json_get_vars port_state
+                       uci -q batch <<-EOF
+                               set system.$cfg.port_state='$port_state'
+                       EOF
+               ;;
+
                timer|oneshot)
                        local delayon delayoff
                        json_get_vars delayon delayoff
index b097fba37cbc175240b4dabffe74b990b0196c14..8c954374a99c466322b07992e2ec591b5221e39a 100755 (executable)
@@ -432,6 +432,25 @@ ucidef_set_led_switch() {
        json_select ..
 }
 
+ucidef_set_led_portstate() {
+       local cfg="led_$1"
+       local name="$2"
+       local sysfs="$3"
+       local port_state="$4"
+
+       json_select_object led
+
+       json_select_object "$1"
+       json_add_string name "$name"
+       json_add_string type portstate
+       json_add_string sysfs "$sysfs"
+       json_add_string trigger port_state
+       json_add_string port_state "$port_state"
+       json_select ..
+
+       json_select ..
+}
+
 ucidef_set_led_default() {
        local cfg="led_$1"
        local name="$2"