PPP 拨号

前面的文章已经看到了ttyUSB ,到了这一步 通过AT 我们就其实可以控制3G网卡发送短信,拨打电话了.

要连接网络还需要PPP

1. 下载  https://download.samba.org/pub/ppp/

2.交叉编译 make CC=arm-none-linux-gnueabi-gcc   

3.将生成的 char pppd pppdump pppstats 复制到  /usr/bin 目录下

4.编辑拨号脚本文件

4.1 wcdma-chat-disconnect

ABORT"ERROR"
ABORT "NODIALTONE"
SAY"\nSending break to the modem\n"
'' "\K"
''"+++ATH"
SAY"\nGoodbay\n"

4.2chat-wcdma-connect

TIMEOUT 5
ABORT 'NO CARRIER'
ABORT 'ERROR'
ABORT 'NODIALTONE'
ABORT 'BUSY'
ABORT 'NO ANSWER'
''  \rAT
OK  \rATZ
OK \rAT+CGDCONT=1,"IP","3GNET",,0,0
OK-AT-OK ATDT*99#
CONNECT \d\c

4.3 wcdma

nodetach
lock
/dev/ttyUSB0
115200
user "card"
password "card"
crtscts
show-password
usepeerdns
noauth
noipdefault
novj
novjccomp
noccp 
defaultroute 
ipcp-accept-local
ipcp-accept-remote
connect '/usr/sbin/chat -s -v -f chat-wcdma-connect'
disconnect '/usr/sbin/chat -s -v -f chat-wcdma-disconnect' 

copy以上三个 文件到/etc/ppp/peers


注意标点符号!

5. 开始拨号了  

终端输入命令   pppd call wcdma

终端开始打印

timeout set to 5 seconds

abort on (NO CARRIER)
abort on (ERROR)
abort on (NODIALTONE)
abort on (BUSY)
abort on (NO ANSWER)
send (^MAT^M)
expect (OK)
AT^M^M
OK
 -- got it


send (^MATZ^M)
expect (OK)
^M
ATZ^M^M
OK
 -- got it


send (^MAT+CGDCONT=1,"IP","3GNET",,0,0^M)
expect (OK)
^M
AT+CGDCONT=1,"IP","3GNET",,0,0^M^M
OK
 -- got it


send (ATDT*99#^M)
expect (CONNECT)
^M
ATDT*99#^M^M
CONNECT
 -- got it


send (\d)
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB0
CHAP authentication succeeded
CHAP authentication succeeded
Could not determine remote IP address: defaulting to 10.64.64.64
local  IP address 10.188.107.188

至此,网卡已连接上网络.


再将ppp0设置为默认路由,route add default dev ppp0 即可通过ppp0 通道连接网络.

你可能感兴趣的:(Linux)