aboutsummaryrefslogtreecommitdiffstats
path: root/package/rssileds/files
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-08-13 14:01:34 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-08-13 14:01:34 +0000
commit6bbfb56a1093b0fa7ba5a3d865649bd7be63a566 (patch)
treeb62f3434d0f492dc7f248af8631b17167aa25b63 /package/rssileds/files
parent593d4aff091d69b75b4aad0ba47fd69a3e0510a3 (diff)
downloadupstream-6bbfb56a1093b0fa7ba5a3d865649bd7be63a566.tar.gz
upstream-6bbfb56a1093b0fa7ba5a3d865649bd7be63a566.tar.bz2
upstream-6bbfb56a1093b0fa7ba5a3d865649bd7be63a566.zip
new package: rssileds daemon
rssileds is a small user-space process to control LEDs by polling the signal quality reported by a WiFi interface. By using the iwinfo library, rssileds is independent of the WiFi driver used. It supports pwm controlled LEDs and may by used to nicely fade through all colors in real-time of the rainbow while only wasting very little CPU time and a small constant amount of system memory. An example configuration for the ALL0258N will follow in the next patch. This is a slightly improved version of rssileds, now quality values are in percent and stuff is written to syslog. Signed-off-by: Daniel Golle <dgolle@allnet.de> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@33163 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/rssileds/files')
-rw-r--r--package/rssileds/files/rssileds.init75
1 files changed, 75 insertions, 0 deletions
diff --git a/package/rssileds/files/rssileds.init b/package/rssileds/files/rssileds.init
new file mode 100644
index 0000000000..b0d262725b
--- /dev/null
+++ b/package/rssileds/files/rssileds.init
@@ -0,0 +1,75 @@
+#!/bin/sh /etc/rc.common
+# (C) 2012 Daniel Golle, Allnet GmbH <dgolle@allnet.de>
+
+START=96
+STOP=96
+RSSILEDS_BIN="/usr/sbin/rssileds"
+
+SERVICE_DAEMONIZE=1
+SERVICE_WRITE_PID=1
+
+start_rssid() {
+ local name
+ local dev
+ local threshold
+ local refresh
+ local leds
+ config_get name $1 name
+ config_get dev $1 dev
+ config_get threshold $1 threshold
+ config_get refresh $1 refresh
+ leds="$( cur_iface=$1 ; config_foreach get_led led )"
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_start $RSSILEDS_BIN $dev $refresh $threshold $leds
+}
+
+stop_rssid() {
+ local dev
+ config_get dev $1 dev
+ SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
+ service_stop $RSSILEDS_BIN
+}
+
+get_led() {
+ local name
+ local sysfs
+ local trigger
+ local iface
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ config_get iface $1 iface
+ config_get minq $1 minq
+ config_get maxq $1 maxq
+ config_get offset $1 offset
+ config_get factor $1 factor
+ [ "$trigger" = "rssi" ] || return
+ [ "$iface" = "$cur_iface" ] || return
+ [ ! "$minq" ] || [ ! "$maxq" ] || [ ! "$offset" ] || [ ! "$factor" ] && return
+ echo "none" > /sys/class/leds/$sysfs/trigger
+ echo "$sysfs $minq $maxq $offset $factor"
+}
+
+off_led() {
+ local name
+ local sysfs
+ local trigger
+ config_get sysfs $1 sysfs
+ config_get name $1 name "$sysfs"
+ config_get trigger $1 trigger "none"
+ [ "$trigger" = "rssi" ] || return
+ echo "0" > /sys/class/leds/$sysfs/brightness
+}
+
+start() {
+ [ -e /sys/class/leds/ ] && [ -x "$RSSILEDS_BIN" ] && {
+ config_load system
+ config_foreach start_rssid rssid
+ }
+}
+
+stop() {
+ config_load system
+ config_foreach stop_rssid rssid
+ config_foreach off_led led
+}