| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (C) 2011 OpenWrt.org |
| 4 | # based on ar71xx |
| 5 | # |
| 6 | |
| 7 | COMMIT_TELEPHONY=0 |
| 8 | |
| 9 | set_relay() { |
| 10 | local cfg="relay_$1" |
| 11 | local gpio=$1 |
| 12 | local val=$2 |
| 13 | |
| 14 | uci -q get telephony.$cfg && return 0 |
| 15 | |
| 16 | uci batch <<EOF |
| 17 | set telephony.$cfg='relay' |
| 18 | set telephony.$cfg.gpio='$gpio' |
| 19 | set telephony.$cfg.value='$val' |
| 20 | EOF |
| 21 | COMMIT_TELEPHONY=1 |
| 22 | } |
| 23 | |
| 24 | set_port() { |
| 25 | local cfg="port$1" |
| 26 | local id=$1 |
| 27 | local led=$2 |
| 28 | |
| 29 | uci -q get telephony.$cfg && return 0 |
| 30 | |
| 31 | uci batch <<EOF |
| 32 | set telephony.$cfg='port' |
| 33 | set telephony.$cfg.id='$id' |
| 34 | set telephony.$cfg.led='$led' |
| 35 | set telephony.$cfg.noring='0' |
| 36 | set telephony.$cfg.nodial='0' |
| 37 | EOF |
| 38 | COMMIT_TELEPHONY=1 |
| 39 | } |
| 40 | |
| 41 | . /lib/lantiq.sh |
| 42 | |
| 43 | board=$(lantiq_board_name) |
| 44 | |
| 45 | case "$board" in |
| 46 | ARV7525PW) |
| 47 | set_relay 31 1 |
| 48 | set_port 0 "soc:green:fxs1" |
| 49 | #set_port 1 "soc:green:fxs2" |
| 50 | ;; |
| 51 | esac |
| 52 | |
| 53 | [ "$COMMIT_TELEPHONY" == "1" ] && uci commit telephony |
| 54 | |
| 55 | exit 0 |
| 56 | |