sim900芯片—GPRS模块ppp拨号上网

-----------------------------------------------------------------------
Cross compiler:arm-linux-gcc-4.5.4
Linux kernel version:linux-3.0
Development board:fl2440
Author:  Yuzhonghan <754270866@qq.com>

-----------------------------------------------------------------------

博文提醒:在开发GPRS模块时所准备的开通GPRS流量的sim卡需要能正常使用!!!

一.GPRS概述:

GSM模块,是将GSM射频芯片、基带处理芯片、存储器、功放器件等集成在一块线路板上,具有独立的操作系统、GSM射频处理、基带处理并提供标准接口的功能模块。GSM模块根据其提供的数据传输速率又可以分为GPRS模块、EDGE模块和纯短信模块。短信模块只支持语音和短信服务。GPRS,可说是GSM的延续。它经常被描述成“2.5G”,也就是说这项技术位于第二代(2G)和第三代(3G)移动通讯技术之间。GPRS的传输速率从56K到114Kbps不等,理论速度最高达171k。相对于GSM的9.6kbps的访问速度而言,GPRS拥有更快的访问数据通信速度,GPRS技术还具有在任何时间、任何地点都能实现连接,永远在线、按流量计费等特点。EDGE技术进一步提升了数据传输的速率到384K-473K,被称为”2.75G”,数据传输速率更2倍于GPRS。目前,国内的GSM网络普遍具有GPRS通讯功能,移动和联通的网络都支持GPRS,EDGE在部分省市实现了网络覆盖。 
GPRS模块,是具有GPRS数据传输功能的GSM模块。GPRS模块就是一个精简版的手机,集成GSM通信的主要功能于一块电路板上,具有发送短消息、通话、数据传输等功能。GPRS模块相当于手机的核心部分,如果增加键盘和屏幕就是一个完整的手机。普通电脑或者单片机可以通过RS232串口与GPRS模块相连,通过AT指令控制GPRS模块实现各种基于GSM的通信功能。 
GPRS模块区别于传统的纯短信模块,两者都是GSM模块,但是短信模块只能收发短信和语音通讯,而GPRS模块还具有GPRS数据传输功能。”

二.配置内核支持ppp拨号上网

Generic Driver Options  --->
--- Network device support
      *** CAIF transport drivers ***
<*>   PPP (point-to-point protocol) support
[*]     PPP multilink support (EXPERIMENTAL)
[*]     PPP filtering
<*>     PPP support for async serial ports
<*>     PPP support for sync tty ports
<*>     PPP Deflate compression
<*>     PPP BSD-Compress compression
<*>     PPP MPPE compression (encryption) (EXPERIMENTAL)
<*>     PPP over Ethernet (EXPERIMENTAL)

三.下载解压ppp-2.4.4.tar.gz
http://download.csdn.net/detail/zhyustar/1531748

[Ciel@localhost sim900]$ ls 
ppp-2.4.4  ppp-2.4.4.tar.gz
[Ciel@localhost sim900]$ cd ppp-2.4.4
[Ciel@localhost ppp-2.4.4]$ ./configure 
[Ciel@localhost ppp-2.4.4]$ ls
Changes-2.3  common     contrib  FAQ      linux     modules  pppd     pppstats  README.cbcp     README.linux  README.MSCHAP80  README.pppoe  README.sol2  SETUP
chat         configure  etc.ppp  include  Makefile  PLUGINS  pppdump  README    README.eap-srp  README.MPPE   README.MSCHAP81  README.pwfd   scripts      solaris
[Ciel@localhost ppp-2.4.4]$ cd chat/
[Ciel@localhost chat]$ vim chat.c


[Ciel@localhost chat]$ vim Makefile


[Ciel@localhost pppd]$ vim auth.c


[Ciel@localhost pppd]$ vim Makefile



[Ciel@localhost ppp-2.4.4]$ make

[Ciel@localhost chat]$ ls
chat  chat.8  chat.c  chat.o  Makefile  Makefile.linux  Makefile.sol2

[Ciel@localhost chat]$ file chat
chat: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

[Ciel@localhost pppd]$ file pppd
pppd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

把chat 和 pppd 两个文件  tftp 到开发板并放到  /usr/sbin/ 下

四. 开发板下脚本的编写

在 /etc 下 创建一个 ppp 的文件夹:>: mkdir /etc/ppp

1.在其目录下编写 chat 脚本:



2.编写gprs脚本

在  /etc/ppp/peer/ 下编写GPRS脚本


五.测试

>: ifconfig
eth0      Link encap:Ethernet  HWaddr F2:C1:05:50:86:D7  
          inet addr:192.168.1.111  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:51 Base address:0x2300 

>: ifconfig eth0 down
>: ifconfig

>: pppd call gprs &
>: abort on (BUSY)
abort on (NO ANSWER)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (\nRING\r\n\r\nRING\r)
timeout set to 20 seconds
send (^MAT^M)
expect (OK)
^MAT^M^M
OK
 -- got it


send (AT+CGDCONT=1,"IP","cmnet"^M)
expect (OK)
^M
AT+CGDCONT=1,"IP","cmnet"^M^M
OK
 -- got it


send (ATDT*99***1#^M)
Waiting for connect...
expect (CONNECT)
^M
ATDT*99***1#^M^M
CONNECT
 -- got it


send (^M)
Connect Success!
Serial connection established.
using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyS1
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x37c1dc9c> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <asyncmap 0xa0000> <auth pap>]
sent [LCP ConfAck id=0x1 <asyncmap 0xa0000> <auth pap>]
rcvd [LCP ConfRej id=0x1 <magic 0x37c1dc9c> <pcomp> <accomp>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0>]
No secret found for PAP login
sent [PAP AuthReq id=0x1 user="root" password=<hidden>]
rcvd [PAP AuthAck id=0x1 "Login OK"]
Remote message: Login OK
PAP authentication succeeded
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfReq id=0x1 <addr 192.200.1.21>]
sent [IPCP ConfAck id=0x1 <addr 192.200.1.21>]
rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfNak id=0x2 <addr 10.46.58.195> <ms-dns1 211.137.58.20> <ms-dns3 211.137.64.163>]
sent [IPCP ConfReq id=0x3 <addr 10.46.58.195> <ms-dns1 211.137.58.20> <ms-dns3 211.137.64.163>]
rcvd [IPCP ConfAck id=0x3 <addr 10.46.58.195> <ms-dns1 211.137.58.20> <ms-dns3 211.137.64.163>]
local  IP address 10.46.58.195
remote IP address 192.200.1.21
primary   DNS address 211.137.58.20
secondary DNS address 211.137.64.163

>: ifconfig
ppp0      Link encap:Point-to-Point Protocol  
          inet addr:10.46.58.195  P-t-P:192.200.1.21  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:352 (352.0 B)  TX bytes:205 (205.0 B)



>: ping www.baidu.com
PING www.baidu.com (103.235.46.39): 56 data bytes
64 bytes from 103.235.46.39: seq=0 ttl=47 time=340.735 ms
64 bytes from 103.235.46.39: seq=1 ttl=47 time=335.719 ms
64 bytes from 103.235.46.39: seq=2 ttl=47 time=370.038 ms
64 bytes from 103.235.46.39: seq=3 ttl=47 time=342.606 ms


64 bytes from 103.235.46.39: seq=4 ttl=47 time=339.175 ms
64 bytes from 103.235.46.39: seq=5 ttl=47 time=335.791 ms
64 bytes from 103.235.46.39: seq=6 ttl=47 time=327.735 ms


--- www.baidu.com ping statistics ---
7 packets transmitted, 7 packets received, 0% packet loss
round-trip min/avg/max = 327.735/341.685/370.038 ms
这样呢,就是可以上网了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值