AT Commands for MQTT
No | Command | Description |
C2101 | AT+SMCONF | Set MQTT Parameter |
C2102 | AT+CSSLCFG | SSL Configure |
C2103 | AT+SMSSL | Select SSL Configure |
C2104 | AT+SMCONN | MQTT Connection |
C2105 | AT+SMPUB | Send Packet |
C2106 | AT+SMSUB | Subscribe Packet |
C2107 | AT+SMUNSUB | Unsubscribe Packet |
C2108 | AT+SMSTATE | Inquire MQTT Connection Status |
C2109 | AT+SMPUBHEX | Set SMPUB Data Format to Hex |
C2110 | AT+SMDISC | Disconnection MQTT |
C2101 AT+SMCONF Set MQTT Parameter
T) AT+SMCONF=? |
Response +SMCONF: “MQTTParamTag”,”MQTTParamValue range”
OK |
R) AT+SMCONF? |
Response +SMCONF: <MQTTParamTag>,<MQTTParamValue>
OK |
W) AT+SMCONF=<MQTTParamTag>,<MQTTParamV alue> |
Response OK
or ERROR |
Parameters <MQTTParamTag> “CLIENTID” Client connection id “URL” (indispensable parameter) server URL address “server domain”,[“tcpPort”] “server”: Host or IP “tcpPort”: Port default is 1883 “KEEPTIME” Hold connect time. default is 60s “CLEANSS” Session clean in. Default is 0. Range of values:(0-1). “USERNAME” User name. default null “PASSWORD” Password. default null “QOS” Send packet QOS level. range of values(0~2) “TOPIC” Publish topic name “MESSAGE” Publish message details “RETAIN” Retain identification. Default is 0. Range of values:(0-1) <MQTTParamValue> MQTT Parameter value. Type and supported content depend on related <MQTTParamTag>. |
Example |
AT+SMCONF=”CLIENTID”,”id” OK AT+SMCONF=”KEEPTIME”,60 OK AT+SMCONF=”URL”,”test.mosquitto.org”,”1883″ OK AT+SMCONF=”CLEANSS”,1 OK AT+SMCONF=”QOS”,1 OK AT+SMCONF=”TOPIC”,”will topic” OK AT+SMCONF=”MESSAGE”,”will message” OK AT+SMCONF=”RETAIN”,1 OK |
C2102 AT+SMCONF SSL Configure
W) AT+CSSLCFG=”convert “,<ssltype>,<cname>[,< keyname>[,<passkey>]] |
Response OK If failed: +CME ERROR: <err> |
Parameters <ssltype> 1 QAPI_NET_SSL_CERTIFICATE_E 2 QAPI_NET_SSL_CA_LIST_E 3 QAPI_NET_SSL_PSK_TABLE_E <cname> String type(string should be included in quotation marks): name of cert file <keyname> String type(string should be included in quotation marks):name of key file <passkey> String type (string should be included in quotation marks):value of passkey |
C2103 AT+SMSSL Select SSL Configure
R) AT+SMSSL? |
Response +SMSSL: <index>,<ca list>,<cert name>
OK |
W) AT+SMSSL=<index>,<c a list>,<cert name> |
Response OK or ERROR |
Parameters <index> SSL status, range: 0-6 <ca list> CA_LIST file name, length 20 byte <cert name> CERT_NAME file name, length 20 byte |
Example |
AT+SMSSL=1,calist,certname OK |
C2104 AT+SMCONN MQTT Connection
E) AT+SMCONN |
Response OK or ERROR |
Example |
AT+SMCONN OK |
C2105 AT+SMPUB Send Packet
T) AT+SMPUB=? |
Response +SMPUB: <topic>,<content length>,(0-2),(0-1)
OK |
W) AT+SMPUB=<topic>,<c ontent length>,<qos>,<retain> |
Response OK or ERROR |
Parameters <topic> Subscribe packet <qos> Send packet QOS level, range: 0~2 <content length> Message length, range: 0~512 <retain> Server hold message range: 0~1 |
Example |
AT+SMPUB=”001″,10,1, 1 OK |
C2106 AT+SMSUB Subscribe Packet
T) AT+SMSUB=? |
Response +SMSUB: “topic”,qos
OK |
Response | |
W) AT+SMSUB=<topic>,<q os> |
OK or ERROR |
Parameters <topic> Subscribe packet <qos> Send packet qos level, range: 0~2 |
Example |
AT+SMSUB=”001″,1 OK |
C2107 AT+SMUNSUB Unsubscribe Packet
R) AT+SMUNSUB=? |
Response +SMUNSUB: “topic”
OK |
W) AT+SMUNSUB=<topic> |
Response OK or ERROR |
Parameters <topic> Subscribe subject |
Example |
AT+SMUNSUB=”001″ OK |
C2108 AT+SMSTATE Inquire MQTT Connection Status
R) AT+SMSTATE? |
Response +SMSTATE: <status>
OK |
Parameters <status> 0 Expression MQTT disconnect state 1 Expression MQTT on-line state |
Example |
AT+SMSTATE? +SMSTATE: 1
OK |
C2109 AT+SMPUBHEX Set SMPUB Data Format to Hex
T) AT+SMPUBHEX=? |
Response +SMPUBHEX: (0-1)
OK |
R) AT+ SMPUBHEX? |
Response +SMPUBHEX: <status>
OK |
PARAMETERS <status> 0 SMPUB data format is normal 1 SMPUB data format is hex |
|
W) AT+SMPUBHEX=<statu s> |
Response OK or ERROR |
Parameters <status> SMPUB format status, range: 0~1 |
Example |
AT+SMPUBHEX=1 OK |
C2110 AT+SMDISC Disconnect MQTT
E) AT+SMDISC |
Response OK or ERROR |
Example |
AT+SMDISC OK |