9e09e69074f4195aef9ca05b50dede94f8e4ad4e
[openwrt.git] / target / linux / ramips / base-files / etc / diag.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 OpenWrt.org
4 #
5 #
6
7 . /lib/ramips.sh
8
9 status_led=""
10
11 led_set_attr() {
12 [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2"
13 }
14
15 status_led_set_timer() {
16 led_set_attr $status_led "trigger" "timer"
17 led_set_attr $status_led "delay_on" "$1"
18 led_set_attr $status_led "delay_off" "$2"
19 }
20
21 status_led_on() {
22 led_set_attr $status_led "trigger" "none"
23 led_set_attr $status_led "brightness" 255
24 }
25
26 status_led_off() {
27 led_set_attr $status_led "trigger" "none"
28 led_set_attr $status_led "brightness" 0
29 }
30
31 get_status_led() {
32 case $(ramips_board_name) in
33 dir-300-b1 | dir-600-b1 | dir-600-b2)
34 status_led="d-link:green:status"
35 ;;
36 esr-9753)
37 status_led="esr-9753:orange:power"
38 ;;
39 f5d8235-v1)
40 set_usb_led "f5d8235-v1:green:usb"
41 ;;
42 fonera20n)
43 status_led="fonera20n:green:power"
44 ;;
45 hw550-3g)
46 status_led="hw550-3g:green:status"
47 ;;
48 mofi3500-3gn)
49 status_led="mofi3500-3gn:green:status"
50 ;;
51 nbg-419n)
52 status_led="nbg-419n:green:power"
53 ;;
54 nw718)
55 status_led="nw718:amber:cpu"
56 ;;
57 omni-emb)
58 status_led="emb:green:status"
59 ;;
60 pwh2004)
61 status_led="pwh2004:green:power"
62 ;;
63 rt-n15)
64 status_led="rt-n15:blue:power"
65 ;;
66 v22rw-2x2)
67 status_led="v22rw-2x2:green:security"
68 ;;
69 w502u)
70 status_led="alfa:blue:wps"
71 ;;
72 whr-g300n)
73 status_led="whr-g300n:green:router"
74 ;;
75 wli-tx4-ag300n)
76 status_led="buffalo:blue:power"
77 ;;
78 wl-351)
79 status_led="wl-351:amber:power"
80 ;;
81 esac
82 }
83
84 set_state() {
85 get_status_led
86
87 case "$1" in
88 preinit)
89 insmod leds-gpio
90 status_led_set_timer 200 200
91 ;;
92 failsafe)
93 status_led_set_timer 50 50
94 ;;
95 done)
96 status_led_on
97 ;;
98 esac
99 }
This page took 0.040947 seconds and 3 git commands to generate.