ESP8266 安信可固件 MQTT AT指令

9.1 AT+MQTTUSERCFG - Set MQTT User Config
Set Command:
AT+MQTTUSERCFG=<LinkID>,<scheme>,<"client_id">,<"username">,<"password">,
<cert_key_ID>,<CA_ID>,<"path">
AT+MQTTUSERCFG=0,1,"6a5f37b09f5baca0f173164855883352","username","password",0,0,""
Response:
OK
Parameters:
<LinkID>: only supports link ID 0 for now
<scheme>:
1: MQTT over TCP
2: MQTT over TLS(no certificate verify)
3: MQTT over TLS(verify server certificate)
4: MQTT over TLS(provide client certificate)
5: MQTT over TLS(verify server certificate and provide client certificate)
6: MQTT over WebSocket(based on TCP)
7: MQTT over WebSocket Secure(based on TLS, no certificate verify)
8: MQTT over WebSocket Secure(based on TLS, verify server certificate)
9: MQTT over WebSocket Secure(based on TLS, provide client certificate)
10: MQTT over WebSocket Secure(based on TLS, verify server certificate and provide client certificate)
<client_id>: MQTT client ID, max length 256Bytes
<username>: the user name to login to the MQTT broker, max length 64Bytes
<password>: the password to login to the MQTT broker, max length 64Bytes
<cert_key_ID>: certificate ID, only supports one certificate of ID 0 for now
证书ID,目前只支持一个ID为0的证书
<CA_ID>: CA ID, only supports one CA of ID 0 for now
<path>: path of the resource, max length 32Bytes

//连接到MQTT服务器
AT+MQTTCONN=<LinkID>,<"host">,<port>,<reconnect>
AT+MQTTCONN=0,"bemfa.com",9501,0

//订阅消息
AT+MQTTSUB=<LinkID>,<"topic">,<qos>
AT+MQTTSUB=0,"LED2002",1

//发布消息
AT+MQTTPUB=<LinkID>,<"topic">,<"data">,<qos>,<retain>
AT+MQTTPUB=0,"LED2002","LED2002",1,0

//断开MQTT连接
AT+MQTTCLEAN=0

posted @ 2022-08-17 17:32  90后大叔666  阅读(1462)  评论(0编辑  收藏  举报