a quick and dirty implementation of EAP220
[openwrt/staging/lynxis.git] / target / linux / ar71xx / base-files / etc / diag.sh
1 #!/bin/sh
2 # Copyright (C) 2009-2013 OpenWrt.org
3
4 . /lib/functions.sh
5 . /lib/functions/leds.sh
6
7 get_status_led() {
8 local board=$(board_name)
9
10 case $board in
11 a40)
12 status_led="a40:green:status"
13 ;;
14 a60)
15 status_led="a60:green:status"
16 ;;
17 alfa-nx)
18 status_led="alfa:green:led_8"
19 ;;
20 all0305)
21 status_led="eap7660d:green:ds4"
22 ;;
23 antminer-s1|\
24 antminer-s3|\
25 antminer-r1|\
26 e1700ac-v2|\
27 e600gac-v2|\
28 eap120|\
29 eap220|\
30 minibox-v1|\
31 packet-squirrel|\
32 som9331|\
33 sr3200|\
34 tl-wr802n-v2|\
35 xd3200)
36 status_led="$board:green:system"
37 ;;
38 ap121f)
39 status_led="$board:green:vpn"
40 ;;
41 ap132|\
42 ap531b0|\
43 cpe505n|\
44 db120|\
45 dr342|\
46 dr344|\
47 rut900|\
48 tew-632brp|\
49 tl-wr942n-v1|\
50 wpj344|\
51 zbt-we1526)
52 status_led="$board:green:status"
53 ;;
54 ap136-010|\
55 ap136-020)
56 status_led="ap136:green:status"
57 ;;
58 ap147-010)
59 status_led="ap147:green:status"
60 ;;
61 ap135-020)
62 status_led="ap135:green:status"
63 ;;
64 archer-c25-v1|\
65 archer-c58-v1|\
66 archer-c59-v1|\
67 archer-c60-v1|\
68 archer-c60-v2|\
69 archer-c7-v4|\
70 archer-c7-v5|\
71 fritz300e|\
72 fritz4020|\
73 fritz450e|\
74 gl-usb150|\
75 mr12|\
76 mr16|\
77 nbg6616|\
78 sc1750|\
79 sc450|\
80 tl-wpa8630|\
81 tl-wr902ac-v1)
82 status_led="$board:green:power"
83 ;;
84 archer-c5|\
85 archer-c7|\
86 tl-mr10u|\
87 tl-mr12u|\
88 tl-mr13u|\
89 tl-wdr4300|\
90 tl-wdr4900-v2|\
91 tl-wr703n|\
92 tl-wr710n|\
93 tl-wr720n-v3|\
94 tl-wr802n-v1|\
95 tl-wr810n|\
96 tl-wr810n-v2|\
97 tl-wr940n-v4|\
98 tl-wr941nd-v6)
99 status_led="tp-link:blue:system"
100 ;;
101 ap90q|\
102 cpe830|\
103 cpe870|\
104 gl-ar300m|\
105 gl-inet|\
106 gl-mifi)
107 status_led="$board:green:lan"
108 ;;
109 ap91-5g|\
110 n5q)
111 status_led="$board:green:signal4"
112 ;;
113 ap96)
114 status_led="$board:green:led2"
115 ;;
116 aw-nr580)
117 status_led="$board:green:ready"
118 ;;
119 bhr-4grv2|\
120 wzr-hp-ag300h|\
121 wzr-hp-g300nh2)
122 status_led="buffalo:red:diag"
123 ;;
124 bsb)
125 status_led="$board:red:sys"
126 ;;
127 bullet-m|\
128 loco-m-xw|\
129 nano-m|\
130 nanostation-m|\
131 nanostation-m-xw|\
132 rocket-m|\
133 rocket-m-xw)
134 status_led="ubnt:green:link4"
135 ;;
136 bxu2000n-2-a1)
137 status_led="bhu:green:status"
138 ;;
139 cap324)
140 status_led="pcs:green:power"
141 ;;
142 c-55|\
143 c-60)
144 status_led="$board:green:pwr"
145 ;;
146 cap4200ag)
147 status_led="senao:green:pwr"
148 ;;
149 cf-e316n-v2|\
150 cf-e520n|\
151 cf-e530n)
152 status_led="$board:blue:wan"
153 ;;
154 cf-e320n-v2)
155 status_led="$board:blue:wlan"
156 ;;
157 cf-e375ac|\
158 cf-e380ac-v1|\
159 cf-e380ac-v2|\
160 cf-e385ac)
161 status_led="$board:blue:wlan2g"
162 ;;
163 cpe510)
164 status_led="tp-link:green:link4"
165 ;;
166 cr3000|\
167 cr5000)
168 status_led="pcs:amber:power"
169 ;;
170 dap-1330-a1|\
171 dgl-5500-a1|\
172 dhp-1565-a1|\
173 dir-505-a1|\
174 dir-600-a1|\
175 dir-615-e1|\
176 dir-615-i1|\
177 dir-615-e4)
178 status_led="d-link:green:power"
179 ;;
180 dir-615-c1)
181 status_led="d-link:green:status"
182 ;;
183 dir-825-b1)
184 status_led="d-link:orange:power"
185 ;;
186 dir-825-c1|\
187 dir-835-a1)
188 status_led="d-link:amber:power"
189 ;;
190 dir-869-a1)
191 status_led="d-link:white:status"
192 ;;
193 dlan-hotspot)
194 status_led="devolo:green:wifi"
195 ;;
196 dlan-pro-500-wp)
197 status_led="devolo:green:wlan-2g"
198 ;;
199 dlan-pro-1200-ac)
200 status_led="devolo:status:wlan"
201 ;;
202 dr531)
203 status_led="$board:green:sig4"
204 ;;
205 dragino2|\
206 oolite-v1)
207 status_led="$board:red:system"
208 ;;
209 dw33d|\
210 r36a)
211 status_led="$board:blue:status"
212 ;;
213 e600g-v2|\
214 oolite-v5.2-dev|\
215 ts-d084|\
216 wifi-pineapple-nano)
217 status_led="$board:blue:system"
218 ;;
219 eap300v2)
220 status_led="engenius:blue:power"
221 ;;
222 ens202ext|\
223 esr900)
224 status_led="engenius:amber:power"
225 ;;
226 eap7660d)
227 status_led="$board:green:ds4"
228 ;;
229 el-m150|\
230 el-mini)
231 status_led="easylink:green:system"
232 ;;
233 ew-balin)
234 status_led="balin:green:status"
235 ;;
236 ew-dorin|\
237 ew-dorin-router)
238 status_led="dorin:green:status"
239 ;;
240 f9k1115v2)
241 status_led="belkin:blue:status"
242 ;;
243 epg5000|\
244 esr1750)
245 status_led="$board:amber:power"
246 ;;
247 gl-ar750|\
248 hiveap-121|\
249 nbg6716|\
250 wam250)
251 status_led="$board:white:power"
252 ;;
253 hiwifi-hc6361)
254 status_led="hiwifi:blue:system"
255 ;;
256 hornet-ub|\
257 hornet-ub-x2)
258 status_led="alfa:blue:wps"
259 ;;
260 ja76pf|\
261 ja76pf2)
262 status_led="jjplus:green:led1"
263 ;;
264 jwap230)
265 status_led="$board:green:led1"
266 ;;
267 koala)
268 status_led="$board:blue:sys"
269 ;;
270 lan-turtle)
271 status_led="$board:orange:system"
272 ;;
273 lbe-m5)
274 status_led="ubnt:green:sys"
275 ;;
276 ls-sr71)
277 status_led="ubnt:green:d22"
278 ;;
279 mc-mac1200r)
280 status_led="mercury:green:system"
281 ;;
282 mr18|\
283 z1)
284 status_led="$board:green:tricolor0"
285 ;;
286 mr600)
287 status_led="$board:orange:power"
288 ;;
289 mr600v2)
290 status_led="mr600:blue:power"
291 ;;
292 mr1750|\
293 mr1750v2)
294 status_led="mr1750:blue:power"
295 ;;
296 mr900|\
297 mr900v2)
298 status_led="mr900:blue:power"
299 ;;
300 mynet-n600|\
301 mynet-n750|\
302 mynet-rext)
303 status_led="wd:blue:power"
304 ;;
305 mzk-w04nu|\
306 mzk-w300nh)
307 status_led="planex:green:status"
308 ;;
309 nbg460n_550n_550nh)
310 status_led="nbg460n:green:power"
311 ;;
312 om2p|\
313 om2p-hs|\
314 om2p-hsv2|\
315 om2p-hsv3|\
316 om2p-hsv4|\
317 om2p-lc|\
318 om2pv2|\
319 om2pv4)
320 status_led="om2p:blue:power"
321 ;;
322 om5p|\
323 om5p-an)
324 status_led="om5p:blue:power"
325 ;;
326 om5p-ac|\
327 om5p-acv2)
328 status_led="om5pac:blue:power"
329 ;;
330 omy-g1)
331 status_led="omy:green:wlan"
332 ;;
333 omy-x1)
334 status_led="omy:green:power"
335 ;;
336 onion-omega)
337 status_led="onion:amber:system"
338 ;;
339 pb44)
340 status_led="$board:amber:jump1"
341 ;;
342 r602n)
343 status_led="$board:green:wan"
344 ;;
345 rb-2011il|\
346 rb-2011ils|\
347 rb-2011l|\
348 rb-2011uas|\
349 rb-2011uas-2hnd)
350 status_led="rb:green:usr"
351 ;;
352 rb-411|\
353 rb-411u|\
354 rb-433|\
355 rb-433u|\
356 rb-450|\
357 rb-450g|\
358 rb-493)
359 status_led="rb4xx:yellow:user"
360 ;;
361 rb-750)
362 status_led="rb750:green:act"
363 ;;
364 rb-750-r2|\
365 rb-750p-pbr2|\
366 rb-750up-r2|\
367 rb-911-2hn|\
368 rb-911-5hn|\
369 rb-911g-2hpnd|\
370 rb-911g-5hpacd|\
371 rb-911g-5hpnd|\
372 rb-941-2nd|\
373 rb-951ui-2nd|\
374 rb-952ui-5ac2nd|\
375 rb-962uigs-5hact2hnt|\
376 rb-lhg-5nd|\
377 rb-map-2nd|\
378 rb-mapl-2nd)
379 status_led="rb:green:user"
380 ;;
381 rb-951ui-2hnd)
382 status_led="rb:green:act"
383 ;;
384 rb-912uag-2hpnd|\
385 rb-912uag-5hpnd|\
386 rb-sxt2n|\
387 rb-sxt5n)
388 status_led="rb:green:power"
389 ;;
390 re355|\
391 re450|\
392 sc300m)
393 status_led="$board:blue:power"
394 ;;
395 rocket-m-ti)
396 status_led="ubnt:green:link6"
397 ;;
398 routerstation|\
399 routerstation-pro)
400 status_led="ubnt:green:rf"
401 ;;
402 rw2458n)
403 status_led="$board:green:d3"
404 ;;
405 smart-300)
406 status_led="nc-link:green:system"
407 ;;
408 qihoo-c301)
409 status_led="qihoo:green:status"
410 ;;
411 t830)
412 status_led="$board:green:usb"
413 ;;
414 tellstick-znet-lite)
415 status_led="tellstick:white:system"
416 ;;
417 tew-673gru)
418 status_led="trendnet:blue:wps"
419 ;;
420 tew-712br|\
421 tew-732br|\
422 tew-823dru)
423 status_led="trendnet:green:power"
424 ;;
425 tl-mr3020|\
426 tl-wr2543n)
427 status_led="tp-link:green:wps"
428 ;;
429 tl-wa750re)
430 status_led="tp-link:orange:re"
431 ;;
432 tl-wa850re|\
433 tl-wa850re-v2)
434 status_led="tp-link:blue:re"
435 ;;
436 tl-wa855re-v1|\
437 tl-wa860re)
438 status_led="tp-link:green:power"
439 ;;
440 tl-mr6400)
441 status_led="tp-link:white:power"
442 ;;
443 tl-mr3220|\
444 tl-mr3220-v2|\
445 tl-mr3420|\
446 tl-mr3420-v2|\
447 tl-wa701nd-v2|\
448 tl-wa801nd-v2|\
449 tl-wa801nd-v3|\
450 tl-wa830re-v2|\
451 tl-wa901nd|\
452 tl-wa901nd-v2|\
453 tl-wa901nd-v3|\
454 tl-wa901nd-v4|\
455 tl-wa901nd-v5|\
456 tl-wdr3320-v2|\
457 tl-wdr3500|\
458 tl-wr1041n-v2|\
459 tl-wr1043n-v5|\
460 tl-wr1043nd|\
461 tl-wr1043nd-v2|\
462 tl-wr1043nd-v4|\
463 tl-wr740n-v6|\
464 tl-wr741nd|\
465 tl-wr741nd-v4|\
466 tl-wr840n-v2|\
467 tl-wr840n-v3|\
468 tl-wr841n-v1|\
469 tl-wr841n-v7|\
470 tl-wr841n-v8|\
471 tl-wr841n-v11|\
472 tl-wr842n-v2|\
473 tl-wr842n-v3|\
474 tl-wr941nd|\
475 tl-wr941nd-v5)
476 status_led="tp-link:green:system"
477 ;;
478 tl-wr841n-v9)
479 status_led="tp-link:green:qss"
480 ;;
481 tl-wr940n-v6)
482 status_led="tp-link:orange:diag"
483 ;;
484 tl-wdr6500-v2)
485 status_led="tp-link:white:system"
486 ;;
487 tube2h)
488 status_led="alfa:green:signal4"
489 ;;
490 unifi)
491 status_led="ubnt:green:dome"
492 ;;
493 uap-pro|\
494 unifiac-lite|\
495 unifiac-pro)
496 status_led="ubnt:white:dome"
497 ;;
498 unifi-outdoor-plus)
499 status_led="ubnt:white:front"
500 ;;
501 airgateway|\
502 airgatewaypro)
503 status_led="ubnt:white:status"
504 ;;
505 wi2a-ac200i)
506 status_led="nokia:green:ctrl"
507 ;;
508 whr-g301n|\
509 whr-hp-g300n|\
510 whr-hp-gn|\
511 wzr-hp-g300nh)
512 status_led="buffalo:green:router"
513 ;;
514 wlae-ag300n)
515 status_led="buffalo:green:status"
516 ;;
517 r6100|\
518 wndap360|\
519 wndr3700|\
520 wndr3700v4|\
521 wndr4300|\
522 wnr2000|\
523 wnr2000-v3|\
524 wnr2200|\
525 wnr612-v2|\
526 wnr1000-v2|\
527 wpn824n)
528 status_led="netgear:green:power"
529 ;;
530 wp543)
531 status_led="$board:green:diag"
532 ;;
533 wpj342|\
534 wpj531|\
535 wpj558)
536 status_led="$board:green:sig3"
537 ;;
538 wpj563)
539 status_led="$board:green:sig1"
540 ;;
541 wrt160nl|\
542 wrt400n)
543 status_led="$board:blue:wps"
544 ;;
545 zcn-1523h-2|\
546 zcn-1523h-5)
547 status_led="zcn-1523h:amber:init"
548 ;;
549 wlr8100)
550 status_led="sitecom:amber:status"
551 ;;
552 esac
553 }
554
555 set_state() {
556 get_status_led
557
558 case "$1" in
559 preinit)
560 status_led_blink_preinit
561 ;;
562 failsafe)
563 status_led_blink_failsafe
564 ;;
565 preinit_regular)
566 status_led_blink_preinit_regular
567 ;;
568 done)
569 status_led_on
570 case $(board_name) in
571 gl-ar300m|\
572 gl-ar750)
573 fw_printenv lc >/dev/null 2>&1 && fw_setenv "bootcount" 0
574 ;;
575 qihoo-c301)
576 local n=$(fw_printenv activeregion | cut -d = -f 2)
577 fw_setenv "image${n}trynum" 0
578 ;;
579 wi2a-ac200i)
580 fw_setenv PKRstCnt 0
581 ;;
582 esac
583 ;;
584 esac
585 }