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