这里记录下调试EC20模块的初始化过程。
先看初始化代码:

void  EC20_Init(void)
{printf("AT\r\n");delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //返回OKwhile (strx == NULL){Clear_Buffer();printf("AT\r\n");delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //返回OK}Clear_Buffer();printf("AT+QGPS?\r\n");//查询当前状态delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+QGPS: 1"); //返回已经上电if (strx == NULL) //如果没上电就上电,上电就不要重复上电printf("AT+QGPS=1\r\n");//对GNSS上电delay_ms(500);printf("ATE1\r\n"); //关闭回显delay_ms(500);Clear_Buffer();printf("AT+CSQ\r\n"); //检查CSQdelay_ms(500);printf("ATI\r\n"); //检查模块的版本号delay_ms(500);/printf("AT+CPIN?\r\n");//检查SIM卡是否在位delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CPIN: READY"); //查看是否返回readywhile (strx == NULL){Clear_Buffer();printf("AT+CPIN?\r\n");delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CPIN: READY"); //检查SIM卡是否在位,等待卡在位,如果卡识别不到,剩余的工作就没法做了}Clear_Buffer();///printf("AT+CREG?\r\n");//查看是否注册GSM网络delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CREG: 0,1"); //返回正常extstrx = strstr((const char *)RxBuffer, (const char *)"+CREG: 0,5"); //返回正常,漫游while (strx == NULL && extstrx == NULL){Clear_Buffer();printf("AT+CREG?\r\n");//查看是否注册GSM网络delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CREG: 0,1"); //返回正常extstrx = strstr((const char *)RxBuffer, (const char *)"+CREG: 0,5"); //返回正常,漫游}Clear_Buffer();/printf("AT+CGREG?\r\n");//查看是否注册GPRS网络delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CGREG: 0,1"); //,这里重要,只有注册成功,才可以进行GPRS数据传输。extstrx = strstr((const char *)RxBuffer, (const char *)"+CGREG: 0,5"); //返回正常,漫游while (strx == NULL && extstrx == NULL){Clear_Buffer();printf("AT+CGREG?\r\n");//查看是否注册GPRS网络delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+CGREG: 0,1"); //,这里重要,只有注册成功,才可以进行GPRS数据传输。extstrx = strstr((const char *)RxBuffer, (const char *)"+CGREG: 0,5"); //返回正常,漫游}Clear_Buffer();printf("AT+COPS?\r\n");//查看注册到哪个运营商,支持移动 联通 电信delay_ms(500);Clear_Buffer();printf("AT+QICLOSE=0\r\n");//关闭socket连接delay_ms(500);Clear_Buffer();printf("AT+QICSGP=1,1,\042CMNET\042,\042\042,\042\042,0\r\n");//接入APN,无用户名和密码delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //开启成功while (strx == NULL){delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); 开启成功}Clear_Buffer();printf("AT+QIDEACT=1\r\n");//去激活delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //开启成功while (strx == NULL){delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //开启成功}Clear_Buffer();printf("AT+QIACT=1\r\n");//激活delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //开启成功while (strx == NULL){delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"OK"); //开启成功}Clear_Buffer();printf("AT+QIACT?\r\n");//获取当前卡的IP地址delay_ms(500);Clear_Buffer();printf("AT+QIOPEN=1,0,\"TCP\",\"47.92.146.210\",10000,0,1\r\n");//这里是需要登陆的IP号码,采用直接吐出模式delay_ms(500);strx = strstr((const char *)RxBuffer, (const char *)"+QIOPEN: 0,0"); //检查是否登陆成功while (strx == NULL){strx = strstr((const char *)RxBuffer, (const char *)"+QIOPEN: 0,0"); //检查是否登陆成功delay_ms(100);}delay_ms(500);Clear_Buffer();
}

这是串口助手抓到的EC20模块返回来的数据:

RDYOK+QGPS: 0OKOKOK
AT+CSQ
+CSQ: 99,99OK
ATI
Quectel
EC20F
Revision: EC20CEFILGR06A05M1GOK
AT+CPIN?
+CPIN: READYOK
AT+CREG?
+CREG: 0,2****************
此处包含无数条重复的,可能是因为第一次开机,
OK
AT+CREG?
+CREG: 0,2
****************OK
AT+CREG?
+CREG: 0,2OK
AT+CREG?
+CREG: 0,1OK
AT+CGREG?
+CGREG: 0,1OK
AT+COPS?
+COPS: 0,0,"CHINA MOBILE",7OK
AT+QICLOSE=0
OK
AT+QICSGP=1,1,"CMNET","","",0
OK
AT+QIDEACT=1
OK
AT+QIACT=1
OK
AT+QIACT?
+QIACT: 1,1,1,"10.104.80.212"OK
AT+QIOPEN=1,0,"TCP","47.92.146.210",10000,0,1
OK+QIOPEN: 0,0

以下是参考移远的手册,截取的关于上述使用的指令的说明:

AT+QGPS Operate GPS Session

Turn on GNSS engine, current <gnssmode> only supports Standalone GNSS. When <fixcount> is 0, GNSS engine will position continuously, you can terminate the session by AT+QGPSEND. When <fixcount> is not 0, and the actual fix times reach to the specified value, GNSS engine will terminate automatically.


这里用到了GNSS的状态查询AT+QGPS?,因为多次上电会报错,所以先查询内部GPS开启情况,再开启。

AT+CSQ Signal Quality Report

AT+CSQ indicates the received signal strength <rssi> and the channel bit error rate <ber>.


这个指令听说是用来查询信号强度和误码率,这里可能是因为还未注册,所以返回的都是99。

ATI Display Product Identification Information

The ATI command delivers a product information text.

这个指令用于查询模块的版本型号。

AT+CPIN Enter PIN

AT+CPIN is used to enter a password or query whether or not the module requires a password which is necessary before it can be operated (SIM PIN, SIM PUK, PH-SIM PIN, etc.).



这个指令用于查询SIM卡的密码类型。实际测试,如果没有插卡,会返回如下消息,所以这个指令可以用来检测SIM卡是否存在。

AT+CPIN?
+CME ERROR: 10

AT+CREG Network Registration

AT+CREG returns the network registration status. The write command sets whether or not to present URC.





手册上这里区分了CDMA和非CDMA,博主对这一块不太熟悉,但是看后面的参数,好像CDMA包含了非CDMA的各种情况。

n 含义
0 关闭网络注册的主动上报结果码
1 打开网络注册的主动上报结果码
2 打开网络注册和位置信息的主动上报结果码
stat 含义 CDMA支持
0 未注册,终端当前并未在搜寻新的运营商 支持
1 已注册本地网络 支持
2 未注册,终端正在搜寻基站 支持
3 注册被拒绝 不支持
4 未知错误 不支持
5 已注册,注册到漫游网络 不支持

这里需要关注的是1和5两种情况。

AT+CGREG Network Registration Status

The AT+CGREG command queries the network registration status and controls the presentation of an unsolicited result code +CGREG: <stat> when <n>=1 and there is a change in the MT‟s GPRS network registration status in GERAN/UTRAN, or unsolicited result code +CGREG: <stat>[,[<lac>],[<ci>],[<Act> ],[<rac>]] when <n>=2 and there is a change of the network cell in GERAN/UTRAN



这个指令和上面的指令差不多,但前者是仅注册网络,后者注册是GPRS或者4G上网功能;个人理解就是第一个注册成功了之后手机上可以显示中国移动,第二个注册成功了手机上会有4G的图标。

AT+COPS Operator Selection

AT+COPS returns the current operators and their status and allows to set automatic or manual network selection.


这个指令用于查询运营商,如+COPS: 0,0,"CHINA MOBILE",7代表自动注册,GB2312类型的运营商,中国移动“CHINA MOBILE”,E-UTRAN代表4G接入。

AT+QICLOSE Close Socket Service

Close the specified socket service by AT+QICLOSE. Depending on the Network, it will take at most 10 seconds (default value, host could modify the time with <timeout>) to return OK or ERROR after executing AT+QICLOSE. Before the response is returned, other AT commands cannot be executed.


指令用于关闭socket连接。

AT+QICSGP Configure Context

Configure the <APN>, <username>, <password> and other contexts by AT+QICSGP. The QoS of the context can be configured by AT+CGQMIN, AT+CGEQMIN, AT+CGQREQ and AT+CGEQREQ.


这里通过AT+QICSGP=1,1,\042CMNET\042,\042\042,\042\042,0\r\n配置1号接入点为CMNET进行联网。

AT+QIDEACT Deactivate PDP Context

AT+QIDEACT will deactivate the specific context <contextID> and close all TCPIP connections set up in this context. Depending on the Network, it may take at most 40 seconds to return OK or ERROR after executing AT+QIDEACT. Before the response is returned, other AT commands cannot be executed


AT+QIDEACT=1将CMNET上的所有连接全部断开。

AT+QIACT Activate PDP Context

Before activating context by AT+QIACT, host should configure the context by AT+QICSGP. After activation, the IP address can be queried by AT+QIACT?. The range of <contextID> is 1-16, but the maximum number of context which can be activated at the same time is 3. Depending on the Network, it may take at most 150 seconds to return OK or ERROR after executing AT+QIACT. Before the response is returned, other AT commands cannot be executed.


AT+QIACT=1将激活接入点CMNET,允许连接。
AT+QIACT?指令还可以查询获取的IP地址。

AT+QIOPEN Start Socket Service

Start a socket service by AT+QIOPEN. The service type can be specified by the parameter <service_type>. The data access mode (buffer access mode, direct push access mode and transparent access mode) can be specified by parameter <access_mode>. The URC “+QIOPEN” indicates whether the socket service is started successfully.


通过AT+QIOPEN=1,0,\"TCP\",\"47.92.146.210\",10000,0,1\r\n即可通过CMNET接入点,socket0,本地的任意端口,直接吐出模式建立TCP连接。

EC20 AT调试笔记相关推荐

  1. 调试笔记--jlink 变量转实时波形小技巧

    调试笔记–jlink 变量转实时波形小技巧 上篇讲了jlink RTT组件在RAM中开辟一段内存,将printf字符串存入然后通过jlink调试接口读取RAM,将printf字符串在jlink-RTT ...

  2. 调试笔记--keil 测量周期小技巧

    调试笔记–keil 测量周期小技巧 本文参考安富莱专题教程第7期 http://www.armbbs.cn/forum.php?mod=viewthread&tid=87176&ext ...

  3. 调试笔记--keil 断点调试小技巧

    调试笔记–keil 断点调试小技巧 给变量打断点 调试不熟悉的项目时,卧槽!怎么这么多全局变量?这玩意又在那修改了??这个时候会给变量打断点就能省好多事. 将要监视的全局变量添加到watch窗口 选中 ...

  4. gpio驱动广播Android,[RK3288][Android6.0] 调试笔记 --- 通用GPIO驱动控制LED【转】

    Platform: ROCKCHIP OS: Android 6.0 Kernel: 3.10.92 由于板子没有lcd无法得知sd卡升级是否完成,因此使用LED显示. Recovery中升级完成后控 ...

  5. keil4怎么移植其他人的程序_【调试笔记】韦东山:在100ask_imx6ull上移植使用六轴传感器ICM20608...

    之前发了LCD调试笔记,大家很感兴趣,所以这次再来一篇:六轴传感器ICM20608驱动移植笔记,大家还需要什么移植笔记?可以留言.我们尽量满足. 1.1 移植思路 先找到驱动:也许内核里已经有,也许需 ...

  6. RK3399 GT1X触摸屏驱动调试笔记

    硬件环境 1.Firefly AIO-3399(AI)开发版: 2.恒智的5寸电容触摸屏800X480,I2C驱动支持GT5688. 操作系统 Android 7.2 for rockship Ste ...

  7. Rockchip基于RK3566/RK3568 WiFi AP6256调试笔记

    1.开发平台 CPU:RK3566 编译环境:Ubuntu18.04 内核版本:kernel 4.19 2.目的 因为RK3566/RK3568支持SDIO3.0并且向下兼有SDIO2.0接口,由于核 ...

  8. 雅马哈四轴机器人调试笔记

    雅马哈四轴机器人调试笔记 1.0 先简单说下硬件,如下图对着插就行,雅马哈四轴主要硬件有控制器跟机械手,机械手到控制器主要有4跟电机接口电缆,每2个轴有一个编码器接口电缆,每根轴有一个配置的数据备份电 ...

  9. OMAP3530-mini调试笔记(2)

    PS:USB不能正常工作的根本原因参见调试笔记(3) 各个版本的x-loader和u-boot对kernel的支持情况: U-Boot 2011.12-00010-ga3eb89c (Jan 29 2 ...

最新文章

  1. js中!和!!的区别及用法
  2. SpringBoot项目下resources文件夹下的静态资源浏览器无法访问
  3. SHA-1算法c语言实现
  4. yaml for java_细数Java项目中用过的配置文件(YAML篇)
  5. SQL SERVER-Extendevent系统视图
  6. 从逻辑回归到神经网络
  7. Spring集成Memcached三种方式(一)
  8. [python教程入门学习]使用Python六步制作小鸟管道游戏(附源码)
  9. Session【常见问题请见下图】
  10. 122 Python程序中的进程池和线程池
  11. 网络安全-跨站脚本攻击(XSS)的原理、攻击及防御
  12. 微信公众号模板消息配置和发送
  13. ps手机计算机图标教程,ps制作手机图标的方法
  14. 细说 Java 中的浅克隆与深克隆
  15. mac 您没有权限打开应用程序_Mac应用程序无法打开或文件损坏的处理方法
  16. uts大学计算机排名,uts是什么大学
  17. 小鹤双拼 - 微软拼音自动配置双拼方案
  18. 【企业架构设计实战】0 企业数字化转型和升级:架构设计方法与实践
  19. P2404 自然数的拆分问题(洛谷)
  20. 微信公众号调起扫码功能

热门文章

  1. ES安装启动及could not find java in bundled jdk at /opt/elasticsearch/elasticsearch-7.9.1/jdk/bin/java报错
  2. 5G的到来,对IDC行业的影响
  3. 取消cfg文件默认打开方式记事本
  4. urv中保研碰撞测试结果_中保研碰撞测试 成绩最好的前十 没想到你是这样的丰田...
  5. LED 控制卡 单元板 接口引脚定义
  6. pytorch查看通道数 维数 尺寸大小
  7. php新建代码片段,非常实用的PHP代码片段(重点推荐)_PHP教程
  8. 【vue】前端通过腾讯接口获取用户ip
  9. 2018杭州-云栖大会
  10. SSM整合(用json,easyui,spring实现从数据库查找信息并进行分页)