2011-10-27 20:29:00 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-10-08 08:01:20 +00:00
|
|
|
[ -n "$INCLUDE_ONLY" ] || {
|
|
|
|
NOT_INCLUDED=1
|
|
|
|
INCLUDE_ONLY=1
|
|
|
|
|
|
|
|
. ../netifd-proto.sh
|
|
|
|
. ./ppp.sh
|
|
|
|
init_proto "$@"
|
|
|
|
}
|
2011-10-27 20:29:00 +00:00
|
|
|
|
|
|
|
proto_3g_init_config() {
|
|
|
|
no_device=1
|
|
|
|
available=1
|
|
|
|
ppp_generic_init_config
|
2014-02-18 13:33:52 +00:00
|
|
|
proto_config_add_string "device:device"
|
2011-10-27 20:29:00 +00:00
|
|
|
proto_config_add_string "apn"
|
|
|
|
proto_config_add_string "service"
|
2011-10-27 20:29:14 +00:00
|
|
|
proto_config_add_string "pincode"
|
2014-06-02 12:45:09 +00:00
|
|
|
proto_config_add_string "dialnumber"
|
2011-10-27 20:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
proto_3g_setup() {
|
|
|
|
local interface="$1"
|
|
|
|
local chat
|
|
|
|
|
|
|
|
json_get_var device device
|
|
|
|
json_get_var apn apn
|
|
|
|
json_get_var service service
|
|
|
|
json_get_var pincode pincode
|
2014-06-02 12:45:09 +00:00
|
|
|
json_get_var dialnumber dialnumber
|
2011-10-27 20:29:00 +00:00
|
|
|
|
2014-10-08 08:01:20 +00:00
|
|
|
[ -n "$dat_device" ] && device=$dat_device
|
2016-12-16 11:14:05 +00:00
|
|
|
|
|
|
|
device="$(readlink -f $device)"
|
2011-10-27 20:29:00 +00:00
|
|
|
[ -e "$device" ] || {
|
|
|
|
proto_set_available "$interface" 0
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$service" in
|
|
|
|
cdma|evdo)
|
|
|
|
chat="/etc/chatscripts/evdo.chat"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
chat="/etc/chatscripts/3g.chat"
|
|
|
|
cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
|
|
|
|
if echo "$cardinfo" | grep -q Novatel; then
|
|
|
|
case "$service" in
|
|
|
|
umts_only) CODE=2;;
|
|
|
|
gprs_only) CODE=1;;
|
|
|
|
*) CODE=0;;
|
|
|
|
esac
|
|
|
|
export MODE="AT\$NWRAT=${CODE},2"
|
|
|
|
elif echo "$cardinfo" | grep -q Option; then
|
|
|
|
case "$service" in
|
|
|
|
umts_only) CODE=1;;
|
|
|
|
gprs_only) CODE=0;;
|
|
|
|
*) CODE=3;;
|
|
|
|
esac
|
|
|
|
export MODE="AT_OPSYS=${CODE}"
|
2011-10-27 20:29:10 +00:00
|
|
|
elif echo "$cardinfo" | grep -q "Sierra Wireless"; then
|
|
|
|
SIERRA=1
|
2012-09-22 14:55:17 +00:00
|
|
|
elif echo "$cardinfo" | grep -qi huawei; then
|
2012-08-19 15:59:24 +00:00
|
|
|
case "$service" in
|
|
|
|
umts_only) CODE="14,2";;
|
|
|
|
gprs_only) CODE="13,1";;
|
|
|
|
*) CODE="2,2";;
|
|
|
|
esac
|
|
|
|
export MODE="AT^SYSCFG=${CODE},3FFFFFFF,2,4"
|
2011-10-27 20:29:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$pincode" ]; then
|
|
|
|
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
|
|
|
|
proto_notify_error "$interface" PIN_FAILED
|
|
|
|
proto_block_restart "$interface"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
[ -n "$MODE" ] && gcom -d "$device" -s /etc/gcom/setmode.gcom
|
2011-10-27 20:29:10 +00:00
|
|
|
|
|
|
|
# wait for carrier to avoid firmware stability bugs
|
|
|
|
[ -n "$SIERRA" ] && {
|
|
|
|
gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
|
|
|
|
}
|
2014-06-02 12:45:09 +00:00
|
|
|
|
|
|
|
if [ -z "$dialnumber" ]; then
|
|
|
|
dialnumber="*99***1#"
|
|
|
|
fi
|
|
|
|
|
2011-10-27 20:29:00 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2014-06-02 12:45:09 +00:00
|
|
|
connect="${apn:+USE_APN=$apn }DIALNUMBER=$dialnumber /usr/sbin/chat -t5 -v -E -f $chat"
|
2011-10-27 20:29:00 +00:00
|
|
|
ppp_generic_setup "$interface" \
|
|
|
|
noaccomp \
|
|
|
|
nopcomp \
|
|
|
|
novj \
|
|
|
|
nobsdcomp \
|
|
|
|
noauth \
|
2015-09-15 14:52:47 +00:00
|
|
|
set EXTENDPREFIX=1 \
|
2011-10-27 20:29:00 +00:00
|
|
|
lock \
|
|
|
|
crtscts \
|
|
|
|
115200 "$device"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_3g_teardown() {
|
|
|
|
proto_kill_command "$interface"
|
|
|
|
}
|
|
|
|
|
2017-09-11 13:27:53 +00:00
|
|
|
[ -z "$NOT_INCLUDED" ] || add_protocol 3g
|