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