1. 加入內(nèi)核支持: 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下可執(zhí)行程序pppd, chat, pppdump, pppstats拷貝到開發(fā)板/usr/sbin目錄下
5. mkdir /etc/ppp; mkdir /etc/ppp/peers 然后建立如下4個文件: 1)/etc/ppp/peers/gprs /dev/s3c2410_serial1 115200 nocrtscts ##important! 一定要注意這里,開發(fā)板與PC機(jī)不同,沒有硬件流控,導(dǎo)致我chat總是沒有回應(yīng),折騰了一上午才發(fā)現(xiàn)! nodetach ##去掉該項,撥號就在后臺運(yùn)行。 noauth usepeerdns noipdefault ipcp-accept-local ipcp-accept-remote defaultroute user itlanger 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'
TIMEOUT 5 '' AT OK ATE0
TIMEOUT 60 SAY "Press CTRL-C to break the connection process.\n" OK AT+CGREG=1 OK AT+CGATT=1 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" CONNECT '' SAY "Connect Success!\n"
3) /etc/ppp/pap-secrets itlanger * ''
4) /etc/ppp/chap-secrets itlanger * ''
6. 進(jìn)行撥號連接: [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) 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+CGREG=1^M) expect (OK)
^M
^M OKOK -- got it
send (AT+CGATT=1^M) expect (OK)
^M
^M OKOK -- got it
send (AT+CGDCONT=1,"IP","CMNET"^M) expect (OK)
^M
^M OKOK -- got it
send (AT+CGQMIN=1,0,0,0,0,31^M) expect (OK)
^M
^M OKOK -- got it
send (AT+CGACT=1,1^M) expect (OK)
^M
^M OKOK -- got it
send (ATDT*99***1#^M) timeout set to 60 seconds Waiting for connect... expect (CONNECT)
^M
^M CONNECTCONNECT -- got it
send (^M) Connect Success!
Serial connection established. Using interface ppp0 Connect: ppp0 <--> /dev/s3c2410_serial1 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 CHAP authentication succeeded CHAP authentication succeeded not replacing existing default route via 192.168.0.1 local IP address 10.24.19.4 remote IP address 192.168.254.254 primary DNS address 211.137.160.5 secondary DNS address 211.136.17.107
7. 解決問題: 1)解決出現(xiàn)的警告: 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 只要去掉這兩個文件的權(quán)限即可: chmod 600 /etc/ppp/*-secrets
2) 后臺撥號: 去掉gprs文件中的nodetach 并且 mkdir /var/log
3)關(guān)閉ppp連接 在控制終端中用CTRL-C就可以斷開連接 在后臺可以用如下腳本文件實(shí)現(xiàn): /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. 發(fā)現(xiàn)使用ppp撥號后,就再也不用AT指令建立socket連接了,方便多了。 哈哈。。。
|