페이지 선택
Generic selectors
Exact matches only
Search in title
Search in content
Search in pages
AT Commands For MQTT(S)

 

 

No Command Description
F1601 AT+CMQTTSTART Start MQTT service
F1602 AT+CMQTTSTOP STOP MQTT service
F1603 AT+CMQTTACCQ Acquire a client
F1604 AT+CMQTTREL Release a client
F1605 AT+CMQTTSSLCFG Set the SSL context
F1606 AT+CMQTTWILLTOPIC Input the will topic
F1607 AT+CMQTTWILLMSG Input the will message
F1608 AT+CMQTTDISC Disconnect from server
F1609 AT+CMQTTCONNECT Connect to MQTT server
F1610 AT+CMQTTTOPIC Input the publish message topic
F1611 AT+CMQTTPAYLOAD Input the publish message body
F1612 AT+CMQTTPUB Publish a message to server
F1613 AT+CMQTTSUBTOPIC Input a subscribe message topic
F1614 AT+CMQTTSUB Subscribe a message to server
F1615 AT+CMQTTUNSUBTOPIC Input a unsubscribe message topic
F1616 AT+CMQTTUNSUB Unsubscribe a message to server
F1617 AT+CMQTTCFG Configure the MQTT Context

 

 

 

 

 

F1601   AT+CMQTTSTART     Start MQTT Service

AT+CMQTTSTART is used to start MQTT service by activating PDP context.

You must execute this command before any other MQTT related operations.

E) AT+CMQTTSTART

OK

+CMQTTSTART: <err>

or

+CMQTTSTART: <err>

 OK

or

ERROR

 +CMQTTSTART: <err>

or

+CMQTTSTART: <err>

 ERROR

or

ERROR

 

<err> The result code, please refer to the next page of MQTT err and unsolicited code

 

Example

AT+CMQTTSTART

OK

+CMQTTSTART: 0

 

NOTE

It must be executed before any other MQTT related operations

 

 

 

F1602   AT+CMQTTSTOP      Stop MQTT Service

AT+CMQTTSTOP is used to stop MQTT service.

E) AT+CMQTTSTOP

OK

+CMQTTSTOP: <err>

or

+CMQTTSTOP: <err>

OK

or

ERROR

 +CMQTTSTOP: <err>

or

+CMQTTSTOP: <err>

 ERROR

or

ERROR

 

<err> The result code, please refer to the next page of MQTT err and unsolicited code

 

Example

AT+CMQTTSTOP

OK

+CMQTTSTOP: 0

 

 

 

F1603   AT+CMQTTACCQ     Acquire a Client

AT+CMQTTACCQ is used to acquire a MQTT client.

It must be called before all commands about MQTT connect and after AT+CMQTTSTART.  

T) AT+CMQTTACCQ=?

+CMQTTACCQ: (0-1),(1-128),(0-1),(3-4)

 OK

R) AT+CMQTTACCQ?

+CMQTTACCQ: <client_index>,<clientID>,<server_type>

+CMQTTACCQ: <client_index>,<clientID>,<server_type>

 OK

W) AT+CMQTTACCQ=<client_index>,

<clientID>[,<server_type>

[,<mqtt_version>]]

OK

or

+CMQTTACCQ: <client_index>,<err>

ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<clientID>

The UTF-encoded string.

It specifies a unique identifier for the client.

The string length is from 1 to 128 bytes.

<server_type>

A numeric parameter that identifies the server type.

The default value is 0.

0     MQTT server with TCP

1     MQTT server with SSL/TLS

<mqtt_version>

A numeric parameter that identifies the MQTT protocol version.

The permitted value is 3 or 4.

3     MQTT version 3.1

4     MQTT version 3.1.1

<err> The result code, please refer to the next page of MQTT err and unsolicited code

 

Example

AT+CMQTTACCQ=0,”client test0″,0,4

OK

 

NOTE

It must be called before all commands about MQTT connect and after AT+CMQTTSTART

 

 

 

F1604   AT+CMQTTREL     Release a Client

AT+CMQTTREL is used to release a MQTT client. It must be called after AT+CMQTTDISC and before AT+CMQTTSTOP.

T) AT+CMQTTREL=?

+CMQTTREL: (0-1)

 OK

R) AT+CMQTTREL? OK
W) AT+CMQTTREL=<client_index>

OK

or

+CMQTTREL: <client_index>,<err>

ERROR

or

ERROR

Maximum Response Time 120000ms

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<err> The result code, please refer to the next page of MQTT err and unsolicited code

 

Example

AT+CMQTTREL=0

OK

 

 NOTE

It can be called when client does not connect to server

 

 

 

 

F1605   AT+CMQTTSSLCFG     Set the SSL Context

AT+CMQTTSSLCFG is used to set the SSL context which to be used in the SSL connection when it will connect to a SSL/TLS MQTT server.

It must be called before AT+CMQTTCONNECT and after AT+CMQTTSTART.

The setting will be cleared after AT+CMQTTCONNECT failed or AT+CMQTTDISC.

 

Note: If you don’t set the SSL context by this command before connecting to server by AT+CMQTTCONNECT,

the CMQTTCONNECT operation will use the SSL context as same as index <session_id>

(the 1st parameter of AT+CMQTTCONNECT) when connecting to the server.

T) AT+CMQTTSSLCFG=?

+CMQTTSSLCFG: (0,1),(0-9)

 OK

R) AT+CMQTTSSLCFG?

+CMQTTSSLCFG: <session_id>,[<ssl_ctx_index >]

+CMQTTSSLCFG: <session_id>,[<ssl_ctx_index >]

OK

W) AT+CMQTTSSLCFG=

<session_id>,<ssl_ctx_index>

OK

or

ERROR

  

<session_id>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<ssl_ctx_index>

The SSL context ID which will be used in the SSL connection.

Refer to the <ssl_ctx_index> of AT+CSSLCFG

 

Example

AT+CMQTTSSLCFG=0,1

OK

 

 NOTE

If you don’t set the SSL context by this command before connecting to server by AT+CMQTTCONNECT,

the CMQTTCONNECT operation will use the SSL context

as same as index <session_id> (the 1st parameter of AT+ CMQTTCONNECT) when connecting to the server

 

 

 

F1606   AT+CMQTTWILLTOPIC     Input/Set the Will Topic

AT+CMQTTWILLTOPIC is used to input the topic of will message.

T) AT+CMQTTWILLTOPIC=?

+CMQTTWILLTOPIC: (0-1),(1-1024)

 OK

W) AT+CMQTTWILLTOPIC=

<client_index>,<req_length>

> <input data/topic here>

OK

or

+CMQTTWILLTOPIC: <client_index>,<err>

 ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input topic. The will topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<err> The result code, please refer to the page of MQTT err and unsolicited code

 

Example

AT+CMQTTWILLTOPIC=0,15

>simcomwilltopic

OK

 

 

 

F1607   AT+CMQTTWILLMSG     Input/Set the Will Message

AT+CMQTTWILLMSG is used to input the message body of will message.

T) AT+CMQTTWILLMSG=?

+CMQTTWILLMSG: (0-1),(1-1024),(0-2)

 OK

W) AT+CMQTTWILLMSG=

<client_index>,<req_length>

,<qos>

> <input data/message here>

OK

or

+CMQTTWILLMSG: <client_index>,<err>

 ERROR

or

ERROR

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input data. The will message should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<qos>

The qos value of the will message. The range is from 0 to 2.

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTWILLMSG=0,17,0

>simcomwillmessage

OK

  

 

 

F1608   AT+CMQTTDISC     Disconnect From Server

AT+CMQTTDISC is used to disconnect from the server.

T) AT+CMQTTDISC=?

+CMQTTDISC: (0-1),(0,60-180)

 OK

R) AT+CMQTTDISC?

+CMQTTDISC: 0,<disc_state>

+CMQTTDISC: 1,<disc_state>

 OK

W) AT+CMQTTDISC=<client_index>,<timeout>

OK

 +CMQTTDISC: <client_index>,<err>

or

+CMQTTDISC: <client_index>,<err>

 OK

or

+CMQTTDISC: <client_index>,<err>

 ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<timeout>

The timeout value for disconnection.

The unit is second. The range is 60s to 180s. The default value is 0s (not set the timeout value)

<disc_state>

1    disconnection

0     connection

<err> The result code, please refer to the next page of MQTT err and unsolicited code

 

Example

AT+CMQTTDISC=0,120

OK

+CMQTTDISC: 0,0

 

 

 

F1609   AT+CMQTTCONNECT     Connect to MQTT Server

 AT+CMQTTCONNECT is used to connect to a MQTT server.

Note: If you don’t set the SSL context by AT+CMQTTSSLCFG before connecting a SSL/TLS MQTT server by AT+CMQTTCONNECT,

it will use the <client_index> (the 1st parameter of AT+CMQTTCONNNECT) SSL context when connecting to the server.

T) AT+CMQTTCONNECT=?

+CMQTTCONNECT: (0-1),(9-256),(1-64800),(0-1)

 OK

R) AT+CMQTTCONNECT?

+CMQTTCONNECT:

0[,<server_addr>,<keepalive_time>,<clean_session>[,<user_name>[,<pass_word>]]]

+CMQTTCONNECT:

1[,<server_addr>,<keepalive_time>,<clean_session>[,<user_name>[,<pass_word>]]]

 OK

W) AT+CMQTTCONNECT=<client_index>,

<server_addr>,<keepalive_time>,

<clean_session>[,<user_name>

[,<pass_word>]]

OK

 +CMQTTCONNECT: <client_index>,<err>

or

+CMQTTCONNECT: <client_index>,<err>

ERROR

or

ERROR

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<server_addr>

The string that described the server address and port.

The range of the string length is 9 to 256 bytes.

The string should be like this “tcp://116.247.119.165:5141”, must begin with “tcp://”.

If the <server_addr> not include the port, the default port is 1883.

<keepalive_time>

The time interval between two messages received from a client.

The client will send a keep-alive packet when there is no message sent to server after song long time.

The range is from 1s to 64800s (18 hours)

<clean_session>

The clean session flag.

The value range is from 0 to 1, and default value is 0.

0     the server must store the subscriptions of the client after it disconnected.

This includes continuing to store QoS 1 and QoS 2 messages for the subscribed topics

so that they can be delivered when the client reconnects.

The server must also maintain the state of in-flight messages being delivered at the point the connection is lost.

This information must be kept until the client reconnects.

1     the server must discard any previously maintained information about the client

and treat the connection as “clean”. The server must also discard any state when the client disconnects.

<user_name>

The user name identifies the name of the user which can be used for authentication when connecting to server.

The string length is from 1 to 256 bytes.

<password>

The password corresponding to the user which can be used for authentication when connecting to server.

The string length is from 1 to 256 bytes.

<err> The result code, please refer to the page of MQTT err and unsolicited code

 

Example

AT+CMQTTCONNECT=0,”tcp://hooleeping.com:8883″,60,1

OK

+CMQTTCONNECT: 0,0

 

NOTE

If you don’t set the SSL context by AT+CMQTTSSLCFG before connecting a SSL/TLS MQTT server by AT+CMQTTCONNECT,

it will use the <client_index> (the 1st parameter of AT+CMQTTCONNECT) SSL context when connecting to the server.

                                                                                                                     

 

  

F1610   AT+CMQTTTOPIC     Input The Publish Message Topic

 

T) AT+CMQTTTOPIC=?

+CMQTTTOPIC: (0-1),(1-1024)

 OK

W) AT+CMQTTTOPIC=<client_index>,<req_length>

> 

<input data here>

OK

or

+CMQTTTOPIC: <client_index>,<err>

 ERROR

or

ERROR

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input topic data.

The publish message topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTTOPIC=0,11

>simcomtopic

OK

 
NOTE

The topic will be clean after execute AT+CMQTTPUB

 

 

  

F1611   AT+CMQTTPAYLOAD     Input The Publish Message Body

 

T) AT+CMQTTPAYLOAD=?

+CMQTTPAYLOAD: (0-1),(1-10240)

 OK

W) AT+CMQTTPAYLOAD=<client_index>,<req_length>

> 

<input data here>

OK

+CMQTTPAYLOAD: <client_index>,<err>

 ERROR

or

ERROR

  

<client_index>

A numeric parameter that identifies a client. The range of permitted values is 0 to 1.

<req_length>

The length of input message data. The publish message should be UTF-encoded string.

The range is from 1 to 10240 bytes

<err> The result code, please refer to to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTPAYLOAD=0,13

>simcompayload

OK

 

NOTE

The payload will be clean after execute AT+CMQTTPUB

 

 

 

F1612   AT+CMQTTPUB     Publish A Message To Server

 

T) AT+CMQTTPUB=?

+CMQTTPUB: (0-1),(0-2),(60-180),(0-1),(0-1)

 OK

W) AT+CMQTTPUB=<client_index>,<qos>,<pub_timeout>[,<ratained> [,<dup>]]

OK

 +CMQTTPUB: <client_index>,<err>

or

+CMQTTPUB: <client_index>,<err>

 ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<qos>

The publish message’s qos.

The range is from 0 to 2.

0     at most once

1     at least once

2     exactly once

<pub_timeout>

The publishing timeout interval value.

Since the client publish a message to server, it will report failed if the client receive no

response from server after the timeout value seconds. The range is from 60s to 180s

<ratained>

The retain flag of the publish message. The value is 0 or 1. The default value is 0.

When a client sends a PUBLISH to a server, if the retain flag is set to 1,

the server should hold on to the message after it has been delivered to the current subscribers

<dup>

The dup flag to the message. The value is 0 or 1. The default value is 0.

The flag is set when the client or server attempts to re-deliver a message

<err> The result code, please refer toto next page of MQTT err and unsolicited code

 

Example

AT+CMQTTPUB=0,0,120

OK

+CMQTTPUB: 0,0

 

 

 

F1613   AT+CMQTTSUBTOPIC     Input a Subscribe Message Topic

  

T) AT+CMQTTSUBTOPIC=?

+CMQTTSUBTOPIC: (0-1),(1-1024),(0-2)

 OK

W) AT+CMQTTSUBTOPIC=

<client_index>,<req_length>,<qos>

> <input data here>

OK

or

+CMQTTSUBTOPIC: <client_index>,<err>

ERROR

or

ERROR

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input topic data. The publish message topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

NOTE: The max length of the total cached topics is 5120

<qos>

The publish message’s qos.

The range is from 0 to 2.

0     at most once

1     at least once

2     exactly once

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTSUBTOPIC=0,11,0

>simcomtopic

OK

 

NOTE

The topic will be clean after executing AT+CMQTTSUB.

 

 

 

 F1614   AT+CMQTTSUB      Subscribe a Message to Server

 

T) AT+CMQTTSUB=?

+CMQTTSUB: (0-1),(1-1024),(0-2),(0-1)

 OK

Subscribe one or more topics

which input by AT+CMQTTSUBTOPIC

 

W) AT+CMQTTSUB=<client_index>

[,<dup>]

OK

 +CMQTTSUB: <client_index>,<err>

or

+CMQTTSUB: <client_index>,<err>

ERROR

or

ERROR

Subscribe one topic

W) AT+CMQTTSUB=<client_index>,

<reqLength>,<qos>[,<dup>]

> <input data here>

OK

+CMQTTSUB: <client_index>,<err>

or

+CMQTTSUB: <client_index>,<err>

 ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input topic data.

The message topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<qos>

The publish message’s qos.

The range is from 0 to 2.

0     at most once

1     at least once

2     exactly once

<dup>

The dup flag to the message. The value is 0 or 1. The default value is 0.

The flag is set when the client or server attempts to re-deliver a message.

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTSUB=0

OK

+CMQTTSUB: 0,0

 

 

 

F1615   AT+CMQTTUNSUBTOPIC     Input a Unsubscribe Message Topic

 

T) AT+CMQTTUNSUBTOPIC=?

+CMQTTUNSUBTOPIC: (0-1),(1-1024)

 OK

W) AT+CMQTTUNSUBTOPIC=<client_index>,<req_length>

> <input data here>

OK

or

+CMQTTUNSUBTOPIC: <client_index>,<err>

ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client. The range of permitted values is 0 to 1.

<req_length>

The length of input topic data. The publish message topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTUNSUBTOPIC=0,11

>simcomtopic

OK

 

NOTE

The max length of the total cached topics is 5120.

The topic will be clean after execute AT+CMQTTUNSUB.

 

 

 

F1616   AT+CMQTTUNSUB     Unsubscribe A Message To Server  

T) AT+CMQTTUNSUB=?

+CMQTTUNSUB: (0-1),(1-1024),(0-1)

 OK

Unsubscribe one or more topics

which input by AT+CMQTTUNSUBTOPIC

 

W) AT+CMQTTUNSUB=<client_ index>

,<dup>

OK

 +CMQTTUNSUB: <client_index>,<err>

or

+CMQTTUNSUB: <client_index>,<err>

 ERROR

or

ERROR

Unsubscribe one topic

W) AT+CMQTTUNSUB=<client_ index>

,<reqLength>,<dup>

> <input data here>

OK

+CMQTTUNSUB: <client_index>,<err>

or

+CMQTTUNSUB: <client_index>,<err>

ERROR

or

ERROR

 

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<req_length>

The length of input topic data.

The message topic should be UTF-encoded string.

The range is from 1 to 1024 bytes.

<dup>

The dup flag to the message.

The value is 0 or 1.

The default value is 0.

The flag is set when the client or server attempts to re-deliver a message.

<err> The result code, please refer to next page of MQTT err and unsolicited code

 

Example

AT+CMQTTUNSUB =0,0

OK

+CMQTTUNSUB: 0,0

 

 

 

F1617   AT+CMQTTCFG     Configure The MQTT Context

T) AT+CMQTTCFG=?

+CMQTTCFG: “checkUTF8”,(0-1),(0-1)

+CMQTTCFG: “optimeout”,(0-1),(20-120)

OK

R) AT+CMQTTCFG?

+CMQTTCFG: 0,<checkUTF8_flag>,<optimeout_val>

+CMQTTCFG: 1,<checkUTF8_flag>,<optimeout_val>

OK

Configure the check UTF8 flag of   

the specified MQTT client context.

W) AT+CMQTTCFG=”checkUTF8″,

<client_index>,<checkUTF8_flag>

OK

or

+CMQTTCFG: <client_index>,<err>

 OK

or

ERROR

Configure the max timeout interval of 

the send or receive data operation

W) AT+CMQTTCFG=”optimeout “,

<client_index>,<optimeout_val>

OK

or

+CMQTTCFG: <client_index>,<err>

OK

or

ERROR

Configure the device information

for Alibaba cloud

W) AT+CMQTTCFG=”aliauth”,< client_index>,”<productkey>”,”<devicename>”,”<devic esecret>”

OK

or

+CMQTTCFG: <client_index>,<err>

 OK

or

ERROR

Configure the active urc flag of

the specified MQTT client context

W) AT+CMQTTCFG=”acturc”,<

client_index>,<acturc_val>

OK

or

+CMQTTCFG: <client_index>,<err>

 OK

or

ERROR

  

<client_index>

A numeric parameter that identifies a client.

The range of permitted values is 0 to 1.

<checkUTF8_flag>

The flag to indicate whether to check the string is UTF8 coding or not, the default value is 1.

0     Not check UTF8 coding.

1     Check UTF8 coding.

<optimeout_val>

The max timeout interval of sending or receiving data operation.

The range is from 20 seconds to 120 seconds, the default value is 120 seconds.

<err> The result code, please refer to next page of MQTT err and unsolicited code

  

Example

AT+CMQTTCFG=”checkUTF8″,0,0

OK

AT+CMQTTCFG=”optimeout”,0,120

OK

 

NOTE

It must be called before AT+CMQTTCONNECT and after AT+CMQTTACCQ. The setting will be cleared after AT+CMQTTREL

 

 

 

 

 

Adsense

EMW3070

Viewed Page List