Chinaunix首页 | 论坛 | 博客
  • 博客访问: 110601
  • 博文数量: 13
  • 博客积分: 489
  • 博客等级: 一等列兵
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-12 10:06
文章分类

全部博文(13)

文章存档

2011年(13)

分类: LINUX

2011-04-07 09:21:59

现在开始介绍如何实现ppp拨号上网。在/system/etc下创建ppp目录,并在ppp目录下创建以下文件:
 
1.init.gprs-pppd
  1. #!/system/bin/sh
  2. # An unforunate wrapper script
  3. PPPD_PID=
  4. /system/bin/setprop "net.gprs.ppp-exit" ""
  5. /system/bin/log -t pppd "Starting pppd"
  6. /system/bin/pppd call gprs $*
  7. PPPD_EXIT=$?
  8. PPPD_PID=$!
  9. /system/bin/log -t pppd "pppd exited with $PPPD_EXIT"
  10. /system/bin/setprop "net.gprs.ppp-exit" "$PPPD_EXIT"
  11. exit $PPPD_EXIT

2.gprs-connect-chat

  1. ABORT 'BUSY'
  2. ABORT 'NO CARRIER'
  3. ABORT 'ERROR'
  4. ABORT '+CME ERROR: 100'
  5. "" AT
  6. OK AT+CGDCONT=1,"IP","CMNET"
  7. OK AT+CGEQREQ=1,2,128,384,0,0,0,0,"0E0","0E0",,0,0
  8. OK AT
  9. OK AT
  10. OK ATS0=0
  11. OK AT
  12. OK AT
  13. OK ATDT*98*1#
  14. CONNECT
3.gprs-disconnect-chat
  1. ABORT OK
  2. ABORT BUSY
  3. ABORT DELAYED
  4. ABORT "NO ANSWER"
  5. ABORT "NO CARRIER"
  6. ABORT "NO DIALTONE"
  7. ABORT VOICE
  8. ABORT ERROR
  9. ABORT RINGING
  10. TIMEOUT 12
  11. "" \\k\\k\\k\\d+++ATH
  12. "NO CARRIER-AT-OK" ""
4.ip-up
  1. #!/system/bin/sh
  2. /system/bin/setprop "net.interfaces.defaultroute" "gprs"
  3. /system/bin/setprop "net.gprs.dns1" "$DNS1"
  4. /system/bin/setprop "net.gprs.dns2" "$DNS2"
  5. /system/bin/setprop "net.gprs.local-ip" "$IPLOCAL"
  6. /system/bin/setprop "net.gprs.remote-ip" "$IPREMOTE"
  7. exit 0
5.ip-down
  1. #!/system/bin/sh
  2. case $1 in
  3.     ppp1)
  4.   echo 0 > /proc/sys/net/ipv4/ip_forward;
  5.   ;;
  6. esac
  7. rm /etc/ppp/ppp*.pid
  8. # Use interface name if linkname is not available
  9. NAME=${LINKNAME:-"$1"}
  10. #/system/bin/setprop "net.dns1" ""
  11. #/system/bin/setprop "net.dns2" ""
  12. /system/bin/setprop "net.$NAME.local-ip" ""
  13. /system/bin/setprop "net.$NAME.remote-ip" ""

6.peers/gprs

  1. # This is pppd script, used Huawei EM770W3G Module
  2. # Usage: root>pppd call gprs
  3. /dev/ttyUSB0
  4. 115200
  5. crtscts
  6. modem
  7. debug
  8. nodetach
  9. usepeerdns
  10. noipdefault
  11. defaultroute
  12. user "cmnet"
  13. 0.0.0.0:0.0.0.0
  14. connect '/system/bin/chat -s -v -f /etc/ppp/gprs-connect-chat'
  15. #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) |
给主人留下些什么吧!~~

send_linux2011-04-07 22:45:41

好文章啊,支持兄弟多发原创,嘿嘿