现在开始介绍如何实现ppp拨号上网。在/system/etc下创建ppp目录,并在ppp目录下创建以下文件:
1.init.gprs-pppd
- #!/system/bin/sh
- # An unforunate wrapper script
- PPPD_PID=
- /system/bin/setprop "net.gprs.ppp-exit" ""
- /system/bin/log -t pppd "Starting pppd"
- /system/bin/pppd call gprs $*
- PPPD_EXIT=$?
- PPPD_PID=$!
- /system/bin/log -t pppd "pppd exited with $PPPD_EXIT"
- /system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT"
- exit $PPPD_EXIT
2.gprs-connect-chat
- ABORT 'BUSY'
- ABORT 'NO CARRIER'
- ABORT 'ERROR'
- ABORT '+CME ERROR: 100'
- "" AT
- OK AT+CGDCONT=1,"IP","CMNET"
- OK AT+CGEQREQ=1,2,128,384,0,0,0,0,"0E0","0E0",,0,0
- OK AT
- OK AT
- OK ATS0=0
- OK AT
- OK AT
- OK ATDT*98*1#
- CONNECT
3.gprs-disconnect-chat
- ABORT OK
- ABORT BUSY
- ABORT DELAYED
- ABORT "NO ANSWER"
- ABORT "NO CARRIER"
- ABORT "NO DIALTONE"
- ABORT VOICE
- ABORT ERROR
- ABORT RINGING
- TIMEOUT 12
- "" \\k\\k\\k\\d+++ATH
- "NO CARRIER-AT-OK" ""
4.ip-up
- #!/system/bin/sh
- /system/bin/setprop "net.interfaces.defaultroute" "gprs"
- /system/bin/setprop "net.gprs.dns1" "$DNS1"
- /system/bin/setprop "net.gprs.dns2" "$DNS2"
- /system/bin/setprop "net.gprs.local-ip" "$IPLOCAL"
- /system/bin/setprop "net.gprs.remote-ip" "$IPREMOTE"
- exit 0
5.ip-down
- #!/system/bin/sh
- case $1 in
- ppp1)
- echo 0 > /proc/sys/net/ipv4/ip_forward;
- ;;
- esac
- rm /etc/ppp/ppp*.pid
- # Use interface name if linkname is not available
- NAME=${LINKNAME:-"$1"}
- #/system/bin/setprop "net.dns1" ""
- #/system/bin/setprop "net.dns2" ""
- /system/bin/setprop "net.$NAME.local-ip" ""
- /system/bin/setprop "net.$NAME.remote-ip" ""
6.peers/gprs
- # This is pppd script, used Huawei EM770W3G Module
- # Usage: root>pppd call gprs
- /dev/ttyUSB0
- 115200
- crtscts
- modem
- debug
- nodetach
- usepeerdns
- noipdefault
- defaultroute
- user "cmnet"
- 0.0.0.0:0.0.0.0
- connect '/system/bin/chat -s -v -f /etc/ppp/gprs-connect-chat'
- #disconnect '/bin/chat -v -f /etc/ppp/gprs-disconnect-chat'
文件创建好后只要在Android启动后进入"Settings(设置)"->"Wireless controls(无线网络)"->"Mobile networks(移动网络)"->"Access Points Name(接入点)",按Menu键弹出界面选择"New APN(新接入点)",一般情况下只要填写"Name(名称)"和"APN"两项即可,"MCC"和"MNC"会随着运行商网络注册成功后自动生成,最后保存。现在就可以通过gprs上网了。
阅读(4130) | 评论(1) | 转发(1) |