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

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/KarinaCristall/article/details/52057340
-----------------------------------------------------------------------
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
这样呢,就是可以上网了。


展开阅读全文

关于gprs模块的ppp拨号上网问题

09-18

大家好!rnrn 小弟最近在搞gprs模块要实现上网,可是遇到了一些问题,希望各位大虾给与帮助,小弟感激rnrn不尽!rn 小弟用的是西门子MC39I的GPRS模块,ucLINUX内核版本2.6.19,内核中已经选中的对ppp协议支rnrn持的相关的选项,还用相应的pppd和chat应用程序。用了三个脚本实现自动拨号上网。rn 我在pc的linux(fc6)中利用那三个脚本已经成功实现了ppp拨号上网。但是利用同样的三个脚本rnrn在我开发板上就拨号不成功。我用串口监视程序分别参看了pc和gprs模块通信时发送和接收的数据,及rnrn开发板和gprs模块通信的时候发送和接收的数据,发现我的开发板按脚本发完at命令之后,就没有向rnrngprs模块发lcp配置请求,gprs模块倒是不停的向开发板发配置请求,由于没有得到应答所以导致连接失rnrn败。(当然在pc和gprs模块通信时双方都是发lcp配置请求的)。rn rn 小弟不清楚到底是怎么回事,发完AT*99***1#,返回CONNECT之后不就应该双发自动的发LCP配置请求吗?怎么我的开发板不向模块发LCP送配置请求呢?希望得到大家的帮助!rnrnpress ctrl-c to endrn defining PDP context...rnATrnOKrnATSCGDCONT=1,"I0","CMNET"^ZOKrnATD*99***1#rnCONNECTrnwaiting for connection...rnlogging in...rn~^?#@!!C 9"N * '"("%&]!.#%B#y%iz~~^?#@!!C 9"N * rn@'"("%&]^Q.#%B#%iz~~^?#@!!# 9"& * '"("%&]Q.#eB#%rniz~~^?#@!!#@9"&@* N"("%&]Q.#%B#%Qz~~^?#@!!# 9"y& *rn z '"("%&]Q.#%BC%iz~~^?#@A!# 9"& * '"("%y&]Q.#z%B#rn%iz~~^?#@!!#y 9"&z * '"(B%&]Q^#%B#Kiz~~^?#@!A# 9"&rn* '"("%&9Q.#%B#%iz~~^?#^@!!# 9"& * '"("%&]Q.Crn%B#%iv~~^?#@!!#z 9"& * `'"(B%&]Q\#%B#%iz~rnNO CARRIE^Rrnrn以下是我的脚本:rn1./etc/ppp/gprsrn/dev/ttyS0rn57600rnconnect '/bin/chat -v -f /etc/ppp/chat-connect-gprs'rndisconnect '/bin/chat -v -f /etc/ppp/chat-disconnect-gprs'rnrnlcp-echo-failure 0rnlcp-echo-interval 0rnrnlockrndebug debug debugrnnodetachrnnocrtsctsrn#nodeflaternlocalrnnoipdefaultrnipcp-accept-localrnipcp-accept-remoternnoauthrndefaultrouternusepeerdnsrnnovjrn#nobsdcomprnnovjccomprnnopcomprnnoaccomprnuser "foo"rnasyncmap 0rn#nomagicrn2./etc/ppp/chat-connect-gprsrnTIMEOUT 5rnECHO ONrnABORT '\nBUSY\r'rnABORT '\nERROR\r'rnABORT '\nNO ANSWER\r'rn#ABORT '\nNO CARRIER\r'rn#ABORT '\nNO DIALTONE\r'rn#ABORT '\nNO RINGING\r\n\r\nRINGING\r'rnTIMEOUT 12rnSAY "press ctrl-c to end"rnSAY "\n defining PDP context...\n"rn"" ATrn#OK ATE1rn#OK 'AT+CGCLASS="B"'rn#OK AT+CSQrn#OK AT+CGATT?rn#OK AT+CGATT=1rn#OK AT+CGATT?rnOK 'AT+CGDCONT=1,"IP","CMNET"'rn#OK AT+CGQREQ=1,0,0,3,0,0rn#OK AT+CGACT=1,1rn#OK AT+CGREG?rnOK ATD*99***1#rnCONNECT ""rnTIMEOUT 120rnSAY "\nwaiting for connection..."rnSAY "\nlogging in..."rnrn3./etc/ppp/chat-disconnect-gprsrnABORT "BUSY"rnABORT "ERROR"rnABORT "NO DIALTONE"rnSAY "SENDING break"rn"" "\K"rn"" "+++ATH"rnSAY "PDP context detached"rnrn 论坛

没有更多推荐了,返回首页