ar71xx: AP136 user-space support
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2009 OpenWrt.org
4 #
5 #
6
7 . /lib/ar71xx.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 $(ar71xx_board_name) in
33 alfa-nx)
34 status_led="alfa:green:led_8"
35 ;;
36 ap136)
37 status_led="ap136:green:status"
38 ;;
39 ap81)
40 status_led="ap81:green:status"
41 ;;
42 ap83)
43 status_led="ap83:green:power"
44 ;;
45 ap96)
46 status_led="ap96:green:led2"
47 ;;
48 aw-nr580)
49 status_led="aw-nr580:green:ready"
50 ;;
51 bullet-m | rocket-m | nano-m | nanostation-m)
52 status_led="ubnt:green:link4"
53 ;;
54 db120)
55 status_led="db120:green:status"
56 ;;
57 dir-600-a1 |\
58 dir-615-e4)
59 status_led="d-link:green:power"
60 ;;
61 dir-615-c1)
62 status_led="d-link:green:status"
63 ;;
64 dir-825-b1)
65 status_led="d-link:orange:power"
66 ;;
67 eap7660d)
68 status_led="eap7660d:green:ds4"
69 ;;
70 hornet-ub)
71 status_led="alfa:blue:wps"
72 ;;
73 ja76pf | \
74 ja76pf2)
75 status_led="jjplus:green:led1"
76 ;;
77 ls-sr71)
78 status_led="ubnt:green:d22"
79 ;;
80 mzk-w04nu | \
81 mzk-w300nh)
82 status_led="planex:green:status"
83 ;;
84 nbg460n_550n_550nh)
85 status_led="nbg460n:green:power"
86 ;;
87 om2p)
88 status_led="om2p:blue:power"
89 ;;
90 pb44)
91 status_led="pb44:amber:jump1"
92 ;;
93 rb-411 | rb-411u | rb-433 | rb-433u | rb-450 | rb-450g | rb-493)
94 status_led="rb4xx:yellow:user"
95 ;;
96 rb-750)
97 status_led="rb750:green:act"
98 ;;
99 routerstation | routerstation-pro)
100 status_led="ubnt:green:rf"
101 ;;
102 rw2458n)
103 status_led="rw2458n:green:d3"
104 ;;
105 tew-632brp)
106 status_led="tew-632brp:green:status"
107 ;;
108 tew-673gru)
109 status_led="trendnet:blue:wps"
110 ;;
111 tl-mr3020)
112 status_led="tp-link:green:wps"
113 ;;
114 tl-mr3220 | \
115 tl-mr3420 | \
116 tl-wa901nd | \
117 tl-wa901nd-v2 | \
118 tl-wr1041n-v2 | \
119 tl-wr1043nd | \
120 tl-wr741nd | \
121 tl-wr741nd-v4 | \
122 tl-wr841n-v1 | \
123 tl-wr841n-v7 | \
124 tl-wr941nd)
125 status_led="tp-link:green:system"
126 ;;
127 tl-wdr4300 | \
128 tl-wr703n)
129 status_led="tp-link:blue:system"
130 ;;
131 tl-wr2543n)
132 status_led="tp-link:green:wps"
133 ;;
134 unifi)
135 status_led="ubnt:green:dome"
136 ;;
137 whr-g301n | \
138 whr-hp-g300n | \
139 whr-hp-gn | \
140 wzr-hp-g300nh)
141 status_led="buffalo:green:router"
142 ;;
143 wzr-hp-g300nh2)
144 status_led="buffalo:red:diag"
145 ;;
146 wndr3700)
147 status_led="wndr3700:green:power"
148 ;;
149 wnr2000)
150 status_led="wnr2000:green:power"
151 ;;
152 wp543)
153 status_led="wp543:green:diag"
154 ;;
155 wrt400n)
156 status_led="wrt400n:blue:wps"
157 ;;
158 wrt160nl)
159 status_led="wrt160nl:blue:wps"
160 ;;
161 zcn-1523h-2 | zcn-1523h-5)
162 status_led="zcn-1523h:amber:init"
163 ;;
164 esac;
165 }
166
167 set_state() {
168 get_status_led
169
170 case "$1" in
171 preinit)
172 insmod leds-gpio
173 insmod ledtrig-default-on
174 insmod ledtrig-timer
175 status_led_set_timer 200 200
176 ;;
177 failsafe)
178 status_led_set_timer 50 50
179 ;;
180 done)
181 status_led_on
182 ;;
183 esac
184 }