AT命令网络拨号上网

基础概念概述: 参考如下两个连接博客,在此表示感谢

http://www.360doc.com/content/15/0805/10/18945873_489618176.shtml

ppp拨号与用at命令实现gprs网络通信有什么区别?ppp拨号完成的哪一步骤?
先通过AT命令,让设备激活PDP,然后PC切换到数据模式,由操作系统发起PPP协商,获取IP地址和鉴权,然后就可以上网了。

https://blog.csdn.net/caijiwyj/article/details/90769663

 ISP:  ["中国联通", "中国移动", "中国电信"];
 APN:  ["3gnet", "cmnet", "internet"];
DIALNUM:["*99#", "*99#", "*99#"];

AT命令操作都需要用户名和密码。默认即可;

1,at+cpin?  准备

2. AT+CFUN=1 启用通信3g模块

3. AT+CGDCONT=1,"IP","internet",,0,0
设置环境包含一组与 PDP 相关的参数

4. ATD*99# 拨号

返回CONNECT   表示at操作DPD(分组数据协议)完成;

at命令操作的所有内容完成; 剩下由pc机器的ppp模块和服务商协商,获取IP地址和鉴权;

==================================================================

参考 资料:

pdf:    ML7810 LTE模块AT指令集_V1.0

电信文档:https://wenku.baidu.com/view/ef82e5efb8f67c1cfad6b874.html

==============================================================

#comgt -s EVDO_conn.scr -d /dev/ttyUSB1   执行at命令脚本文件

#microcom -s 115200 /dev/ttyUSB1                  DTE和DCE串口通信工具

=================================================================

EVDO_conn.scr

opengt
set com 460800n81
set senddelay 0.03
waitquiet 1 0.2

let $x=$rpipe("nvram get modem_pin")
let a=len($x)
if a<4 goto ready
if a>8 goto ready
let c=0

:test
let $c=$mid($x,c,1)
if $c<"0" goto ready
if $c>"9" goto ready
inc c
if c<a goto test

send "AT+CPIN?^m"
waitfor 10 "SIM PIN","SIM PUK","READY","ERROR","ERR","COMMAND NOT SUPPORT"
if % = 0 goto enterpin
goto ready

:enterpin
send "AT+CPIN=\""+$x+"\"^m"
waitfor 10 "OK","ERR","ERROR","+CME ERROR","COMMAND NOT SUPPORT"
if % = -1 goto pintimeerror
if % = 0 goto ready

:pinerror
let $e="PIN Error! Caution - entering the wrong PIN code three times will lock the SIM!"
print $e+"\n"
system "logger -t comgt \""+$e+"\""
send "ATH^m"
exit 1

:pintimeerror
let $e="ERROR: timeout, device did not respond to PIN command entry!"
print $e+"\n"
system "logger -t comgt \""+$e+"\""
send "ATH^m"
exit 1

:ready
send "ATZ^m"
waitfor 10 "OK","ERR","ERROR"
if % = -1 goto timeerror
if % = 0 goto atcmd
goto error

:atcmd
let $x=$rpipe("nvram get modem_cmd")
let a=len($x)
if a<3 goto dial

send $x+"^m"
waitfor 10 "OK","ERR","ERROR","+CME ERROR","COMMAND NOT SUPPORT"
if % = 0 goto dial
let $e="ERROR sending user AT command! Try to continue..."
print $e+"\n"
system "logger -t comgt \""+$e+"\""

:dial
let $x=$rpipe("nvram get modem_dialnum")
let a=len($x)
if a=0 goto error

send "ATD"+$x+"^m"
waitfor 20 "CONNECT","ERR","ERROR"
if % = -1 goto timeerror
if % = 0 goto dialok
goto error

:dialok
let $e="CONNECTION ESTABLISHED!"
print $e+"\n"
exit 0

:error
let $e="ERROR: CONNECT ERROR!"
print $e+"\n"
system "logger -t comgt \""+$e+"\""
send "ATH^m"
exit 1

:timeerror
let $e="ERROR: CONNECT TIMEOUT!"
print $e+"\n"
system "logger -t comgt \""+$e+"\""
send "ATH^m"
exit 1

=========================================================

猜你喜欢

转载自www.cnblogs.com/Sam-2018/p/AT_DEMO.html