适用于移远的NB模块BC20,BC26,BC28,BC35
調試流程
AT+QMTCFG="version",0,4
OK
AT+QMTOPEN=0,"222.221.18.162",1883
OK
+QMTOPEN: 0,0
AT+QMTCONN=0,"123456","ABC","A123456"
OK
+QMTCONN: 0,0,0
AT+QMTSUB=0,1,"123",0
OK
+QMTSUB: 0,1,0,0
AT+QMTPUB=0,0,0,0,"123"
>i am bc28 sj
OK
+QMTPUB: 0,0,0
+QMTRECV: 0,0,"123",i am bc28 sj
AT+QMTPUB=0,0,0,0,"123"
>
+QMTRECV: 0,0,"123",5587
i am bc28 sj
OK
+QMTPUB: 0,0,0
+QMTRECV: 0,0,"123",i am bc28 sj
流程解析
AT+QMTCFG="version",0,4 //设置MQTT的版本为3.1
OK
AT+QMTOPEN=0,"222.221.18.162",1883 //连接服务器,服务器IP为:222.221.18.162(需要改成自己的),端口号为:1883
OK
+QMTOPEN: 0,0 //需要返回这个之后才能继续往下做
AT+QMTCONN=0,"123456","ABC","A123456" //发送验证信息,123456是clientID,ABC是用户名,A123456是密码
OK
+QMTCONN: 0,0,0 //连接服务器成功
AT+QMTSUB=0,1,"123",0 //订阅信息 123是Topic
AT+QMTPUB=0,0,0,0,"123" //发布信息 123是Topic
>//出现>的时候才发以下内容
i am bc28 sj //这是内容
1A //发十六进制的1A作为结束符号。
|