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