ath9k: fix another tx locking issue
[openwrt.git] / package / comgt / files-old / 3g.sh
1 set_3g_led() {
2 # set on WRT54G3G only
3 [ -f /proc/diag/model ] || return 0
4 grep -q "WRT54G3G" /proc/diag/model >/dev/null || return 0
5 echo "$1" > /proc/diag/led/3g_green
6 echo "$2" > /proc/diag/led/3g_blue
7 grep -q "WRT54G3G$" /proc/diag/model >/dev/null || return 0
8 echo "$3" > /proc/diag/led/3g_blink
9 }
10
11 scan_3g() {
12 local device
13 config_get device "$1" device
14
15 # try to figure out the device if it's invalid
16 [ -n "$device" -a -e "$device" ] || {
17 for device in /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/tts/2 /dev/usb/tts/0 /dev/noz0; do
18 [ -e "$device" ] && {
19 config_set "$1" device "$device"
20 break
21 }
22 done
23 }
24
25 # enable 3G with the 3G button by default
26 local button
27 config_get button "$1" button
28 [ -z "$button" ] && {
29 config_set "$1" button 1
30 }
31 }
32
33 stop_interface_3g() {
34 stop_interface_ppp "$1"
35 set_3g_led 0 0 0
36 killall gcom >/dev/null 2>/dev/null
37 }
38
39 setup_interface_3g() {
40 local iface="$1"
41 local config="$2"
42 local chat="/etc/chatscripts/3g.chat"
43
44 local device
45 config_get device "$config" device
46
47 local maxwait
48 config_get maxwait "$config" maxwait
49 maxwait=${maxwait:-20}
50 while [ ! -e "$device" -a $maxwait -gt 0 ];do # wait for driver loading to catch up
51 maxwait=$(($maxwait - 1))
52 sleep 1
53 done
54
55 for module in slhc ppp_generic ppp_async; do
56 /sbin/insmod $module 2>&- >&-
57 done
58
59 local apn
60 config_get apn "$config" apn
61
62 local service
63 config_get service "$config" service
64
65 local pincode
66 config_get pincode "$config" pincode
67
68 local mtu
69 config_get mtu "$config" mtu
70
71 set_3g_led 1 0 1
72
73 # figure out hardware specific commands for the card
74 case "$service" in
75 cdma|evdo) chat="/etc/chatscripts/evdo.chat";;
76 *)
77 cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
78 if echo "$cardinfo" | grep Novatel; then
79 case "$service" in
80 umts_only) CODE=2;;
81 gprs_only) CODE=1;;
82 *) CODE=0;;
83 esac
84 mode="AT\$NWRAT=${CODE},2"
85 elif echo "$cardinfo" | grep Option; then
86 case "$service" in
87 umts_only) CODE=1;;
88 gprs_only) CODE=0;;
89 *) CODE=3;;
90 esac
91 mode="AT_OPSYS=${CODE}"
92 fi
93 # Don't assume Option to be default as it breaks with Huawei Cards/Sticks
94
95 test -z "$pincode" || {
96 PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
97 echo "$config(3g): Failed to set the PIN code."
98 set_3g_led 0 0 0
99 return 1
100 }
101 }
102 test -z "$mode" || {
103 MODE="$mode" gcom -d "$device" -s /etc/gcom/setmode.gcom
104 }
105 esac
106 set_3g_led 1 0 0
107
108 config_set "$config" "connect" "${apn:+USE_APN=$apn }/usr/sbin/chat -t5 -v -E -f $chat"
109 start_pppd "$config" \
110 noaccomp \
111 nopcomp \
112 novj \
113 nobsdcomp \
114 noauth \
115 lock \
116 crtscts \
117 ${mtu:+mtu $mtu mru $mtu} \
118 115200 "$device"
119 }
This page took 0.04567 seconds and 5 git commands to generate.