Browse Source

wifitoggle: Do not generate error message in case of empty led_sysfs

While an empty led_sysfs definition works as intended (no LED state is
touched), an error message is generated, since the appropriate sysfs
interface does not exist:

          Sat Feb 27 16:42:55 2016 user.err wifitoggle: led:  not found

This patch makes sure that no such error message will be generated.

Signed-off-by: Karol Babioch <karol@babioch.de>
Karol Babioch 9 years ago
parent
commit
f6221d4c65

+ 2
- 1
utils/wifitoggle/Makefile View File

@@ -1,6 +1,7 @@
1 1
 #
2 2
 # Copyright (C) 2010-2014 OpenWrt.org
3 3
 # Copyright (C) 2010 segal.di.ubi.pt
4
+# Copyright (C) 2016 Karol Babioch <karol@babioch.de>
4 5
 #
5 6
 # This is free software, licensed under the GNU General Public License v2.
6 7
 # See /LICENSE for more information.
@@ -10,7 +11,7 @@ include $(TOPDIR)/rules.mk
10 11
 
11 12
 PKG_NAME:=wifitoggle
12 13
 PKG_VERSION:=1
13
-PKG_RELEASE:=4
14
+PKG_RELEASE:=5
14 15
 PKG_LICENSE:=GPL-2.0+
15 16
 
16 17
 PKG_MAINTAINER:=Nuno Goncalves <nunojpg@gmail.com>

+ 3
- 1
utils/wifitoggle/files/wifitoggle.config View File

@@ -4,7 +4,9 @@ config wifitoggle
4 4
 	option persistent	'0' 
5 5
 	option timer		'600'
6 6
 
7
-	option led_sysfs		'wrt160nl:amber:wps'
7
+	#option led_sysfs		'wrt160nl:amber:wps'
8
+	# Leaving this option empty, makes sure that no LED is touched
9
+	option led_sysfs		''
8 10
 	option led_enable_trigger	'timer' 
9 11
 	option led_enable_delayon	'500'
10 12
 	option led_enable_delayoff	'500'

+ 3
- 1
utils/wifitoggle/files/wifitoggle.hotplug View File

@@ -1,7 +1,9 @@
1 1
 # /bin/sh
2 2
 
3 3
 setled() {
4
-        if [ -e /sys/class/leds/${led_sysfs}/brightness ]
4
+        if [ -z "${led_sysfs}" ]; then
5
+            return
6
+        elif [ -e /sys/class/leds/${led_sysfs}/brightness ]
5 7
 	then
6 8
                 [ $led_default -eq 1 ] && echo 1 >/sys/class/leds/${led_sysfs}/brightness
7 9
                 [ $led_default -eq 1 ] || echo 0 >/sys/class/leds/${led_sysfs}/brightness