AT命令网络拨号上网

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

https://www.cnblogs.com/jiangzhaowei/p/9244154.html

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

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

AT+ZGAAT=0
在AT+CFUN=1之前命令用作对 PS 服务进行设置永久在线或用时在线,
其起效时间由当前的附着状态和设置值决定
AT+CGEQREQ? 上下文激活请求发送
AT+CGATT? 查询当前附着/去附着到分组域服务 0未附着
AT+CGATT=1 设置MT 附着1/去附着0到分组域服务
AT+COPS? 多等等 查询卡注册情况
AT+COPS? 搜网
AT+COPS=0 判断是否注册登录,并自动联网

AT+CGACT=1,1 激活/去激活指定的pdp,返回6000通信通道阻塞
AT+CGACT?
ATD*99*1# 设置命令建立 MT 与外部 PDN 的通信通道,包括附着和 PDP 上下文的激活,进入数据态。返回命令态时返回 NO CARRIER

 

AT+CGACT=1,1 激活/去激活指定的pdp,返回6000通信通道阻塞
AT+CGACT?
ATD*99*1# 设置命令建立 MT 与外部 PDN 的通信通道,包括附着和 PDP 上下文的激活,进入数据态。返回命令态时返回 NO CARRIER

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

AT命令状态
PPP数据状态

MS移动台:
  ME移动设备
    MT 移动终端
    TE 终端设备
  用户识别模块SIM

DTE 数据终端设备/TE 终端设备
DCE 数据电路终端设备/TA 终端适配器
PDP 分组数据协议

ps域服务基于ip

lcp 链路层协商

GGSN网关gprs支持节点

IPCP客户端与服务器协商

ppp (DL数据链路层的封装操作)

 

====

1. AT (选填)
2. //可不写ATS0=1(pdp上下文激活请求‘s0’) 或者 ATZ
3. DPD参数配置

AT+CGDCONT=1,"IP","internet",,0,0
AT+CGDCONT=1,"IP","internet"    
AT+CGDCONT=1,"IP",""
选填 AT+ZGAAT=0 AT+CFUN=1
调试使用(选填)
  AT+CGEQREQ?
  AT+CGDCONT=1,"IP",""  //填写参数
  AT+CGATT? //附着
  AT+CGATT=1

AT+CGACT=1,1  激活/去激活指定的pdp

 

4. ATD*99#(拨号) /ATD*98*1# /ATD*99***1# /ATD*99*1#

(3和4时必须填写的选项)

 

posted @ 2020-04-10 18:45  Perry_Lee  阅读(6607)  评论(1编辑  收藏  举报