1. 加入内核支持:
Device Drivers -> Network device support->PPP (point-to-point protocol) support
PPP multilink support (EXPERIMENTAL)
PPP support for async serial ports
PPP support for sync tty ports
PPP Deflate compression
PPP BSD-Compress compression
2. 下载ppp
wget -c ftp://ftp.samba.org/pub/ppp/ppp-2.4.5.tar.gz
3. 交叉编译
# ./configure
# make CC=arm-linux-gcc
4. 将目录下pppd chat pppdump pppstats下可执行程序pppd, chat, pppdump, pppstats拷贝到开发板/usr/sbin目录下
5. mkdir /etc/ppp; mkdir /etc/ppp/peers
然后建立如下4个文件:
1)/etc/ppp/peers/gprs
/dev/ttyS3
115200
nocrtscts
nodetach
noauth
debug
usepeerdns
noipdefault
ipcp-accept-local
ipcp-accept-remote
defaultroute
-chap #NO CHAP
-mschap-v2 # no mschap
user
hide-password
#user itlanger
#user cmnet
0.0.0.0:0.0.0.0
noccp
#persist # AUTO LOOP
connect '/usr/sbin/chat -s -v -f /etc/ppp/chat-gprs-connect'
2) /etc/ppp/chat-gprs-connect
TIMEOUT 5
ECHO ON
ABORT '\nBUSY\r'
ABORT '\nERROR\r'
ABORT '\nNO ANSWER\r'
ABORT '\nNO CARRIER\r'
ABORT '\nNO DIALTONE\r'
SAY "\nsend AT command...\n\n"
TIMEOUT 5
'' AT
OK ATE0
TIMEOUT 60
SAY "Press CTRL-C to break the connection process.\n"
OK AT+CMEE=2
#OK AT+MDC=0
OK AT+CGMR
OK AT+QIHEAD=1
OK 'AT+QICSGP=1,"CMNET"'
OK AT+QIREGAPP
OK AT+QIACT
#OK 'AT+CGDCONT=1,"IP","CMNET"'
#OK AT+CGQMIN=1,0,0,0,0,31
#OK AT+CGACT=1,1
#OK ATDT*99***1
TIMEOUT 60
SAY "Waiting for connect...\n"
#OK AT+QILOCIP
OK atdt*99***1
CONNECT ''
SAY "Connect Success!\n"
3) /etc/ppp/pap-secrets
iitlanger *
#cmnet * cmnet *
4) /etc/ppp/chap-secrets
itlanger * ''
#'' * '' *
6. 进行拨号连接:
[root@srp-arm /]# /usr/sbin/pppd call gprs
# timeout set to 5 seconds
abort on (\nBUSY\r)
abort on (\nERROR\r)
abort on (\nNO ANSWER\r)
abort on (\nNO CARRIER\r)
abort on (\nNO DIALTONE\r)
send AT command...
timeout set to 5 seconds
send (AT^M)
expect (OK)
^M
OKOK
-- got it
send (ATE0^M)
timeout set to 60 seconds
Press CTRL-C to break the connection process.
expect (OK)
^M
^M
OKOK
-- got it
send (AT+CMEE=2^M)
expect (OK)
^M
^M
OKOK
-- got it
send (AT+CGMR^M)
expect (OK)
^M
^M
Revision: M35FAR02A09
Revision: M35FAR02A09^M
^M
OKOK
-- got it
send (AT+QIHEAD=1^M)
expect (OK)
^M
^M
OKOK
-- got it
send (AT+QICSGP=1,"CMNET"^M)
expect (OK)
^M
^M
Call Ready
Call Ready^M
^M
OKOK
-- got it
send (AT+QIREGAPP^M)
expect (OK)
^M
^M
OKOK
-- got it
send (AT+QIACT^M)
timeout set to 60 seconds
Waiting for connect...
expect (OK)
^M
^M
OKOK
-- got it
send (atdt*99***1^M)
expect (CONNECT)
^M
^M
CONNECTCONNECT
-- got it
send (^M)
Connect Success!
Script /usr/sbin/chat -s -v -f /etc/ppp/chat-gprs-connect finished (pid 2319), status = 0x0
Serial connection established.
using channel 20
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS3
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfReq id=0x1 ]
No auth is possible
sent [LCP ConfRej id=0x1 ]
rcvd [LCP ConfNak id=0x1 ]
sent [LCP ConfReq id=0x2 ]
rcvd [LCP ConfReq id=0x2 ]
sent [LCP ConfAck id=0x2 ]
rcvd [LCP ConfAck id=0x2 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x1 ]
sent [IPCP ConfAck id=0x1 ]
rcvd [IPCP ConfRej id=0x1 ]
sent [IPCP ConfReq id=0x2 ]
rcvd [IPCP ConfNak id=0x2 ]
sent [IPCP ConfReq id=0x3 ]
rcvd [IPCP ConfAck id=0x3 ]
local IP address 10.226.235.217
remote IP address 192.168.254.254
primary DNS address 210.21.196.6
secondary DNS address 221.5.88.88
7. 解决问题:
1)解决出现的警告:
Warning - secret file /etc/ppp/pap-secrets has world and/or group access
Warning - secret file /etc/ppp/chap-secrets has world and/or group access
只要去掉这两个文件的权限即可:
chmod 600 /etc/ppp/*-secrets
2) 后台拨号:
去掉gprs文件中的nodetach
并且 mkdir /var/log
3)关闭ppp连接
在控制终端中用CTRL-C就可以断开连接
在后台可以用如下脚本文件实现: /etc/ppp/ppp-off
#!/bin/sh
if [ -r /var/run/ppp0.pid ]; then
kill -INT `cat /var/run/ppp0.pid`
fi
if [ ! "$?" = "0" ]; then
rm -f /var/run/ppp0.pid
echo "ERROR: close ppp0 failed!"
exit 1
fi
echo "SUCCESS: ppp0 was closed!"
exit 0
8. 发现使用ppp拨号后,就再也不用AT指令建立socket连接了,方便多了。
哈哈。。。
9。ATD*99***1, ATD*99***1这条AT命令是做什么用的? PDP激活不就可以传数据了吗?
你上网除了PDP激活,是可以和基站交互了,但是你要接入internet吧,要接入移动计费网关吧,所以总要指定接入点吧,比如中国移动的接入点是cmnet,Modem上面一般有几个位置可以存储多个接入点配置,比如1#位置存cmnet,2#存其他接入点。ATD*99***1#的含义就是从Modem内存中选择1#位置的接入点配置,类推 ATD*99***2#,ATD*99***3#。这个接入点是由其他AT之前写入的。
10.如果你只能ping纯的ip地址,而不能解析域名
将/etc/ppp/resolv.conf 里的内容拷贝到/etc/resolv.conf里面就OK了
# ping
PING (112.80.248.73): 56 data bytes
64 bytes from 112.80.248.73: seq=0 ttl=51 time=548.947 ms
64 bytes from 112.80.248.73: seq=1 ttl=51 time=407.699 ms
64 bytes from 112.80.248.73: seq=2 ttl=51 time=558.580 ms
64 bytes from 112.80.248.73: seq=3 ttl=51 time=616.047 ms
64 bytes from 112.80.248.73: seq=4 ttl=51 time=501.420 ms
64 bytes from 112.80.248.73: seq=5 ttl=51 time=349.401 ms
64 bytes from 112.80.248.73: seq=6 ttl=51 time=355.479 ms
64 bytes from 112.80.248.73: seq=7 ttl=51 time=288.939 ms
64 bytes from 112.80.248.73: seq=8 ttl=51 time=261.486 ms
64 bytes from 112.80.248.73: seq=9 ttl=51 time=296.278 ms
64 bytes from 112.80.248.73: seq=10 ttl=51 time=310.812 ms
附件为配置文件和对应的执行文件ppp.rar
阅读(3932) | 评论(0) | 转发(0) |