diff mbox series

[OpenWrt-Devel,2/3] base-files:fix a bug when add led timer trigger

Message ID 1559618019-5561-1-git-send-email-wurobinson@qq.com
State Accepted, archived
Delegated to: Christian Lamparter
Headers show
Series None | expand

Commit Message

Robinson Wu June 4, 2019, 3:13 a.m. UTC
When I tried to add a led timer tirgger in "target/linux/ramips/base-files/
etc/board.d/01_leds" like below
ucidef_set_led_timer "system" "system" "zhuotk:green:system" "1000" "1000"
it will be failed to add value to "delayon" and "delayoff". This commit fix this
bug.

Signed-off-by: robinson wu <wurobinson@qq.com>
---
 package/base-files/files/lib/functions/uci-defaults.sh | 1 +
 1 file changed, 1 insertion(+)

Comments

Christian Lamparter June 15, 2019, 10:38 a.m. UTC | #1
On Tuesday, June 4, 2019 5:13:39 AM CEST robinson wu wrote:
> When I tried to add a led timer tirgger in "target/linux/ramips/base-files/
> etc/board.d/01_leds" like below
> ucidef_set_led_timer "system" "system" "zhuotk:green:system" "1000" "1000"
> it will be failed to add value to "delayon" and "delayoff". This commit fix this
> bug.
> 
> Signed-off-by: robinson wu <wurobinson@qq.com>
> ---
>  package/base-files/files/lib/functions/uci-defaults.sh | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
> index 315df7b..23bde9a 100755
> --- a/package/base-files/files/lib/functions/uci-defaults.sh
> +++ b/package/base-files/files/lib/functions/uci-defaults.sh
> @@ -463,6 +463,7 @@ _ucidef_set_led_timer() {
>  
>  	_ucidef_set_led_common "$1" "$2" "$3"
>  
> +	json_add_string type timer
Hm, I think I see what's going on. Thank you for noticing this.

I see that _ucidef_set_led_timer is also used by ucidef_set_led_oneshot
which has a different type/trigger.
But package/base-files/files/bin/config_generate's
generate_led() routine's timer|oneshot type case does this:

   set system.$cfg.trigger='$type'

So in a way, for oneshot and timer the type and trigger are the same thing.
(which begs the question if we really need both or not.). But let's worry
about this some other time.

In the mean time, I think this would be a better fit and also fix
the oneshot type in the process. 

json_add_string type "$trigger_name"

>  	json_add_string trigger "$trigger_name"
>  	json_add_int delayon "$delayon"
>  	json_add_int delayoff "$delayoff"
> 

Regards,
Christian
diff mbox series

Patch

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 315df7b..23bde9a 100755
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -463,6 +463,7 @@  _ucidef_set_led_timer() {
 
 	_ucidef_set_led_common "$1" "$2" "$3"
 
+	json_add_string type timer
 	json_add_string trigger "$trigger_name"
 	json_add_int delayon "$delayon"
 	json_add_int delayoff "$delayoff"