0% found this document useful (0 votes)
116 views30 pages

Sim7500 Sim7600 Series MQTT Atc v1.01

Uploaded by

suvankar mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views30 pages

Sim7500 Sim7600 Series MQTT Atc v1.01

Uploaded by

suvankar mandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

LE

FI
SIM7500_SIM7600

AL
Series_MQTT_ATC_V1.01

TI
EN
D
FI
N
O
C
M
O
C
M
SI
Document Title: SIM7500_SIM7600 Series_MQTT AT Command Set
Version: 1.01
Date: 2017-09-20
Status: Release

E
Document ID: SIM7500_SIM7600 Series_MQTT_ATC_V1.01

L
FI
General Notes
SIMCom offers this information as a service to its customers, to support application and

AL
engineering efforts that use the products designed by SIMCom. The information provided is based
upon requirements specifically provided to SIMCom by the customers. SIMCom has not

TI
undertaken any independent search for additional relevant information, including any information
that may be in the customer’s possession. Furthermore, system validation of this product designed

EN
by SIMCom within a larger electronic system remains the responsibility of the customer or the
customer’s system integrator. All specifications supplied herein are subject to change.
D
Copyright
FI

This document contains proprietary technical information which is the property of SIMCom
Limited., copying of this document and giving it to others and the using or communication of the
N

contents thereof, are forbidden without express authority. Offenders are liable to the payment of
damages. All rights reserved in the event of grant of a patent or the registration of a utility model
O

or design. All specification supplied herein are subject to change without notice at any time.
C

Copyright © Shanghai SIMCom Wireless Solutions Ltd. 2017


M
O
C
M
SI
Smart Machine Smart Decision

Contents
Version History ................................................................................................................................. 2
1 Introduction ............................................................................................................................... 3
2 AT commands ........................................................................................................................... 3
2.1 AT+CMQTTSTART Open network ........................................................................... 3
2.2 AT+CMQTTSTOP Close network ............................................................................. 4
2.3 AT+CMQTTACCQ Acquire a client ......................................................................... 5
2.4 AT+CMQTTREL Release a client ............................................................................. 6

E
2.5 AT+CMQTTWILLTOPIC Set the will topic ............................................................. 7

L
2.6 AT+CMQTTWILLMSG Set will message ................................................................ 8

FI
2.7 AT+CMQTTCNCTTIMEOUT Set retry timeout for connection .............................. 9
2.8 AT+CMQTTCONNECT Connect to the server ....................................................... 10
2.9 AT+CMQTTDISC Disconnect from the server ....................................................... 11

AL
2.10 AT+CMQTTTOPIC Set publishing topic ................................................................ 13
2.11 AT+CMQTTPAYLOAD Set publishing message .................................................... 14

TI
2.12 AT+CMQTTPUB Send a PUBLISH message to server .......................................... 15
2.13 AT+CMQTTSUBTOPIC Set one topic for SUBSCRIBE message ......................... 16

EN
2.14 AT+CMQTTSUB Send SUBSCRIBE message to server ........................................ 17
2.15 AT+CMQTTUNSUBTOPIC Set one topic for unsubscribe message ...................... 18
2.16 AT+CMQTTUNSUB Send UNSUBSCRIBE message to server ............................ 19
D
2.17 MQTT URC ................................................................................................................ 21
2.17.1 Disconnect passively ....................................................................................... 21
FI

2.17.2 Receive topic published by MQTT server....................................................... 21


2.18 Return code ................................................................................................................. 23
N

3 Examples ................................................................................................................................. 24
O
C
M
O
C
M
SI

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 1 2017-09-20


Smart Machine Smart Decision

Version History

Data Version Description of change Author


2017-05-25 V1.00 New Version

E
2017-06-21 V1.01 Modify SIM PING value Yueying.ding

L
2017-06-26 V1.01 Modify AT+CMQTTDISC Yueying.ding

FI
AL
TI
SCOPE EN
This document describes how to use the MQTT function of SIM7500/SIM7600
D
series module through AT commands.
The develop software refer to MQTT V3.1.
FI

This document is subject to change without notice at any time.


N
O
C
M
O
C
M
SI

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 2 2017-09-20


Smart Machine Smart Decision

1 Introduction

MQ Telemetry Transport (MQTT) is a lightweight broker-based publish/subscribe messaging


protocol designed to be open, simple, lightweight and easy to implement. This document apply to
MQTT V3.1.

2 AT commands

L E
2.1 AT+CMQTTSTART Open network

FI
Description

AL
This command is used to open the network.

TI
SIM PIN References
YES Vendor
EN
Syntax
D
Execution Command Responses
FI

AT+CMQTTSTART OK
N

+CMQTTSTART: <result>
O

+CMQTTSTART: <result>
C

OK
[+CMQTTSTART: <result>]
M

ERROR
O

Defined values
C

< result >


M

Refer to “Return code” chapter.


SI

Examples
AT+CMQTTSTART
OK

+CMQTTSTART: 0
AT+CMQTTSTART

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 3 2017-09-20


Smart Machine Smart Decision

OK

+CMQTTSTART: 8

2.2 AT+CMQTTSTOP Close network

Description

L E
This command is used to close the network. You should disconnect all of client’s connection before
executing this command.

FI
SIM PIN References
YES Vendor

AL
Syntax

TI
Execution Command Responses
AT+CMQTTSTOP
EN
+CMQTTSTOP: <result>

OK
D
OK
FI

+CMQTTSTOP: <result>
N

[+CMQTTSTOP: <result>]
O

ERROR
C

Defined values
< result >
M

Refer to “Return code” chapter.


O

Examples
C

AT+CMQTTSTOP
+CMQTTSTOP: 0
M
SI

OK
AT+CMQTTSTOP
+CMQTTSTOP: 9

OK

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 4 2017-09-20


Smart Machine Smart Decision

2.3 AT+CMQTTACCQ Acquire a client

Description
This command is used to acquire a client.

SIM PIN References

E
YES Vendor

L
FI
Syntax

Test Command Responses

AL
AT+CMQTTACCQ=? +CMQTTACCQ: (0-<max_client_index>),(1-<
max_clientID_len>)

TI
OK
Read Command
AT+CMQTTACCQ?
Responses
EN
[+CMQTTACCQ: <client_index>, <clientID><CR><LF>
[+CMQTTACCQ: <client_index>, <clientID><CR><LF>]]
D
OK
FI

Write Command Responses


AT+CMQTTACCQ=<client OK
N

_index>, <clientID> +CMQTTACCQ: <client_index>,<result>


O

ERROR
C

Defined values
M

<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
O

<max_client_index>
a numeric parameter that identifies the max client index.
C

< clientID >


M

The UTF-encoded string. It specifies a unqiue identifier for the client. The string length is from 1 to
23.
SI

< max_clientID_len>
23 - The max length of <clientID> string.
<result>
Refer to “Return code” chapter.

Examples

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 5 2017-09-20


Smart Machine Smart Decision

AT+CMQTTACCQ=0,"client c"
OK

2.4 AT+CMQTTREL Release a client

Description

E
This command is used to release a client.

L
FI
SIM PIN References
YES Vendor

AL
Syntax

TI
Test Command Responses
AT+CMQTTREL=? +CMQTTREL: (0-<max_client_index>)
Read Command
AT+CMQTTREL?
Responses
OK
EN
Write Command Responses
D
AT+CMQTTREL OK
FI

=<client_index> +CMQTTREL: <client_index>,<result>


N

ERROR
O

Defined values
C

<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<max_client_index>
M

a numeric parameter that identifies the max client index.


<result>
O

Refer to “Return code” chapter.


C

Examples
M

AT+CMQTTREL=0
SI

OK
AT+CMQTTREL=0
+CMQTTREL: 0,12

ERROR

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 6 2017-09-20


Smart Machine Smart Decision

2.5 AT+CMQTTWILLTOPIC Set the will topic

Description
This command is used to set will topic for the messege.

SIM PIN References

E
YES Vendor

L
FI
Syntax

Test Command Responses

AL
AT+CMQTTWILLTOPIC=? +CMQTTWILLTOPIC:
(0-<max_client_index>),(1-<max_topic_len>)

TI
OK
Read Command
AT+CMQTTWILLTOPIC?
Responses
OK EN
Write Command Responses
D
AT+CMQTTWILLTOPIC= OK
<client_index>,<req_len
FI

+CMQTTWILLTOPIC: <client_index>,<result>
gth>
N

ERROR
O

Defined values
C

<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<max_client_index>
M

a numeric parameter that identifies the max client index.


<max_topic_len>
O

The max length of will topic. The value is 1024


<req_length>
C

The length of input topic. The will topic should be UTF-encoded string. The range is from 1 to
M

1024.
<result>
SI

Refer to “Return code” chapter.

Examples
AT+CMQTTWILLTOPIC=0,10
>

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 7 2017-09-20


Smart Machine Smart Decision

2.6 AT+CMQTTWILLMSG Set will message

Description
This command is used to set will message for the publish message.

SIM PIN References

E
YES Vendor

L
FI
Syntax

Test Command Responses

AL
AT+CMQTTWILLMSG=? +CMQTTWILLMSG:
(0-<max_client_index>),(1-<max_willmsg_len>),(0-2)

TI
OK
Read Command
AT+CMQTTWILLMSG?
Responses
OK EN
Write Command Responses
D
AT+CMQTTWILLMSG=<cl OK
ient_index>,<req_length>,<q
FI

+CMQTTWILLMSG: <client_index>,<result>
os>
N

ERROR
O

Defined values
C

<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<max_client_index>
M

a numeric parameter that identifies the max client index.


<max_willmsg_len>
O

The max length of will message. The value is 10240


<req_length>
C

The length of input will message. The will message should be UTF-encoded string. The range is
M

from 1 to 10240.
<qos>
SI

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


<result>
Refer to “Return code” chapter.

Examples
AT+CMQTTWILLMSG=0,56,1

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 8 2017-09-20


Smart Machine Smart Decision

>

2.7 AT+CMQTTCNCTTIMEOUT Set retry timeout for connection

Description
This command is used to set the timeout interval value for connection.

L E
SIM PIN References

FI
YES Vendor

AL
Syntax

Test Command Responses

TI
AT+CMQTTCNCTTIMEOUT +CMQTTRETCNCTTIMEOUT:
=? (0-<max_client_index>),(10-<max_interval>)

OK
EN
Read Command Responses
D
AT+ + CMQTTCNCTTIMEOUT: <client_index>[,<interval>]
CMQTTCNCTTIMEOUT? [+CMQTTCNCTTIMEOUT: <client_index>[,<interval>]]
FI

OK
N

Write Command Responses


O

AT+ OK
CMQTTCNCTTIMEOUT
C

ERROR
=<client_index>,<interval>

Defined values
M

<client_index>
O

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


<max_client_index>
C

a numeric parameter that identifies the max client index.


M

<max_interval >
The max connect timeout interval value. The value is 180.
SI

<interval >
The timeout interval value for connection. The range is from 10 to 180, 0 is not set the timeout
value. The default value is 0.

Examples
AT+ CMQTTCNCTTIMEOUT=0,60

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 9 2017-09-20


Smart Machine Smart Decision

OK

2.8 AT+CMQTTCONNECT Connect to the server

Description
This command is used to establish connection to the server.

L E
SIM PIN References

FI
YES Vendor

AL
Syntax

Test Command Responses

TI
AT+CMQTTCONNECT=? +CMQTTCONNECT:
(0-<max_client_index>),(<min_srvaddr_len>-<max_srvaddr_len>)

EN
,(0-<max_keepalive_time>),(0-1)

OK
D
Read Command Responses
AT+CMQTTCONNECT? +CMQTTCONNECT:
FI

<client_index>[,<server_addr>,<keepalive_time>,<clean_session>[
,<user_name>[,<pass_word>]]]
N
O

OK
Write Command Responses
C

AT+CMQTTCONNECT=<c OK
lient_index>,<server_addr>,
<keepalive_time>,<clean_se +CMQTTCONNECT: <client_index>,<result>
M

ssion>[,<user_name>[,<pass +CMQTTCONNECT: <client_index>,<result>


_word>]]
O

ERROR
C

Defined values
M

<client_index>
SI

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


<max_client_index>
a numeric parameter that identifies the max client index.
<server_addr>
The string that described the server address and port. The range of the string length is 9 to 256. 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.

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 10 2017-09-20


Smart Machine Smart Decision

<min_srvaddr_len>
The min length of server address, the value is 9.
<max_srvaddr_len>
The max length of server address, the value is 256.
<keepalive_time>
The Keep Alive timer, measured in seconds, defines the maximum time interval between messages
received from a client. The range is from 1s to 64800s (18 hours).
<max_keepalive_time>

E
The max interval value of the keep alive timer

L
<clean_session >

FI
The clean session flag.
0 - the server must store the subscriptions of the client after it disconnects. This includes
continuing to store QoS 1 and QoS 2 messages for the subscribed topics so that they can be

AL
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

TI
reconnects.
1 - the server must discard any previously maintained information about the client and treat the

< user_name >


EN
connection as "clean". The server must also discard any state when the client disconnects.

The user name identifies the name of the user who is connecting, which can be used for
D
authentication. The string length is from 1 to 12.
<pass_word>
FI

The password corresponding to the user who is connecting, which can be used for authentication.
The string length is from 1 to 12.
N

<result>
O

Refer to “Return code” chapter.


C

Examples
AT+CMQTTCONNECT=0,"tcp://116.247.119.165:5141",20,1,”username”,”password”
OK
M

+CMQTTCONNECT: 0,0
O
C

2.9 AT+CMQTTDISC Disconnect from the server


M

Description
SI

This command is used to disconnect from a client to a server.

SIM PIN References


YES Vendor

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 11 2017-09-20


Smart Machine Smart Decision

Syntax

Test Command Responses


AT+CMQTTDISC=? +CMQTTDISC: (0-<max_client_index>),(0, 60-180)

OK
Read Command Responses
AT+CMQTTDISC? [+CMQTTDISC: <client_index>, <disc_state><CR><LF>

E
[+CMQTTDISC: <client_index>, <disc_state><CR><LF>]]

L
FI
OK
Write Command Responses
AT+CMQTTDISC=<client_i OK

AL
ndex>,<timeout>
+CMQTTDISC: <client_index>,<result>

TI
+CMQTTDISC: <client_index>,<result>

ERROR EN
Defined values
D
<client_index>
FI

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


<max_client_index>
N

a numeric parameter that identifies the max client index.


O

<timeout>
a numeric parameter that set timeout value for disconnection. The unit is second. The range is 60s
C

to 180s. The default value is 0s (not set the timeout value).


<disc_state>
1 - disconnection
M

0 - connection
<result>
O

Refer to “Return code” chapter.


C

Examples
M

AT+CMQTTDISC=0, 120
OK
SI

+CMQTTDISC: 0,0

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 12 2017-09-20


Smart Machine Smart Decision

2.10 AT+CMQTTTOPIC Set publishing topic

Description
This command is used to set publishing topic for the client.

SIM PIN References

E
YES Vendor

L
FI
Syntax

Test Command Responses

AL
AT+CMQTTTOPIC=? +CMQTTTOPIC: (0-<max_client_index>),(1-<max_topic_len>)

OK

TI
Read Command Responses
AT+CMQTTTOPIC?
Write Command
OK
Responses
EN
AT+CMQTTTOPIC=<client OK
D
_index>,<req_length><CR> +CMQTTTOPIC: <client_index>,<result>
data for send
FI

ERROR
N

Defined values
O

<client_index>
C

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


<max_client_index>
a numeric parameter that identifies the max client index.
M

<max_topic_len>
a numeric parameter that identifies the max length of topic. The value is 1024.
O

<req_length>
a numeric parameter that identifies the length of input topic. The topic should be UTF-encoded
C

string. The length is from 1 to 1024.


M

<result>
Refer to “Return code” chapter.
SI

Examples
AT+CMQTTTOPIC=0,13
>

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 13 2017-09-20


Smart Machine Smart Decision

2.11 AT+CMQTTPAYLOAD Set publishing message

Description
This command is used to set publishing message for the client.

SIM PIN References

E
YES Vendor

L
FI
Syntax

Test Command Responses

AL
AT+CMQTTPAYLOAD=? +CMQTTPAYLOAD: (0-<client_index>),(1-<max_pubmsg_len>)

OK

TI
Read Command Responses
AT+CMQTTPAYLOAD?
Write Command
OK
Responses
EN
AT+CMQTTPAYLOAD=<c OK
D
lient_index>,<req_length>< +CMQTTPAYLOAD: <client_index>,<result>
CR>data for send
FI

ERROR
N

Defined values
O

<client_index>
C

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


<max_client_index>
a numeric parameter that identifies the max client index.
M

<max_pubmsg_len >
a numeric parameter that identifies the max length of publish message. The value is 10240.
O

<req_length>
a numeric parameter that identifies the length of input message. The message should be
C

UTF-encoded string. The length is from 1 to 10240.


M

<result>
Refer to “Return code” chapter.
SI

Examples
AT+CMQTTPAYLOAD=0,62.
>

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 14 2017-09-20


Smart Machine Smart Decision

2.12 AT+CMQTTPUB Send a PUBLISH message to server

Description
This command is used to publish a message. You should set this command after you set the
publishing topic and message. If the result of publish topic is fail, the client will be disconnect and
user need to connect again.

E
SIM PIN References
YES Vendor

L
FI
Syntax

AL
Test Command Responses
AT+CMQTTPUB=? +CMQTTPUB:
(0-<max_client_index>),(0-<max_qos>),(1-<max_publish_interval

TI
>),(0-1),(0-1)

Read Command
OK
Responses
EN
AT+CMQTTPUB? OK
D
Write Command Responses
FI

AT+CMQTTPUB=<client_i OK
ndex>,<qos>,<publish_inter
N

val>[,<retained>[,<dup>]] +CMQTTPUB: <client_index>,<result>


O

+CMQTTPUB: <client_index>,<result>
C

ERROR

Defined values
M

<client_index>
O

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


<max_client_index>
C

a numeric parameter that identifies the max client index.


< qos>
M

The publish message’s qos. The range is from 0 to 2.


SI

< max_qos>
The max publish message’s qos value.
< publish_interval >
The publishing timeout interval value, from the time client send PUBLISH to client receive the first
response. The range is from 1s to 180s.
< max_publish_interval >
The max publishing timeout interval value.

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 15 2017-09-20


Smart Machine Smart Decision

< retained>
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 (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.
<result>

E
Refer to “Return code” chapter.

L
FI
Examples
AT+CMQTTPUB=0,1,60

AL
OK

+CMQTTPUB: 0,0

TI
EN
2.13 AT+CMQTTSUBTOPIC Set one topic for SUBSCRIBE message

Description
D
This command is used to set one topic for subscribing. You would set this command repeatedly for
FI

more than one subscribing topic.


N

SIM PIN References


YES Vendor
O
C

Syntax

Test Command Responses


AT+CMQTTSUBTOPIC=? +CMQTTSUBTOPIC:
M

(0-<max_client_index>),(1-<max_subtopic_len>),(0-2)
O

OK
C

Read Command Responses


AT+CMQTTSUBTOPIC? OK
M

Write Command Responses


SI

AT+CMQTTSUBTOPIC OK
=<client_index>,<reqLength
>,<qos><CR>data for +CMQTTSUBTOPIC: <client_index>,<result>
send +CMQTTSUBTOPIC: <client_index>,<result>

ERROR

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 16 2017-09-20


Smart Machine Smart Decision

Defined values
<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<max_client_index>
a numeric parameter that identifies the max client index.
< qos>
The publish message’s qos. The range is from 0 to 2.

E
<reqLength>
The input length of subscribe message. The range is from 1 to 1024.

L
< max_subtopic_len >

FI
The max length of subtopic message.
<result>

AL
Refer to “Return code” chapter.

Examples

TI
AT+CMQTTSUBTOPIC=0,9,1
>
EN
D
2.14 AT+CMQTTSUB Send SUBSCRIBE message to server
FI

Description
N

This command is used to subscribe message for the client.


O
C

SIM PIN References


YES Vendor
M

Syntax
O

Test Command Responses


AT+CMQTTSUB=? +CMQTTSUB:
C

(0-<max_client_index>),(1-<max_subtopic_len>),(0-2),(0-1)
M

OK
SI

Read Command Responses


AT+CMQTTSUB? OK
Write Command Responses
/* subcribe one topic*/ OK
AT+CMQTTSUB=<client_i
ndex>,<reqLength>,<qos>[, +CMQTTSUB: <client_index>,<result>

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 17 2017-09-20


Smart Machine Smart Decision

<dup>] +CMQTTSUB: <client_index>,<result>


<CR>data for send
ERROR

/* subcribe one or more topics


which be set by
AT+CMQTTSUBTOPIC*/
AT+CMQTTSUB=<client_i

E
ndex>[,<dup>]

L
FI
Defined values
<client_index>

AL
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<max_client_index>
a numeric parameter that identifies the max client index.

TI
<reqLength>
The input length of subscribe message. The range is from 1 to 1024.
<max_subtopic_len>
The max input length of subscribe topic.
EN
< qos>
D
The publish message’s qos. The range is from 0 to 2.
FI

< dup>
The dup flag to the message. The value is 0 or 1. The default value is 0. The flag is set when the
N

client or server attempts to re-deliver a message.


<result>
O

Refer to “Return code” chapter.


C

Examples
AT+CMQTTSUB=0,9,1,1
M

>
AT+CMQTTSUB=0
O

OK
C

+CMQTTSUB: 0,0
M
SI

2.15 AT+CMQTTUNSUBTOPIC Set one topic for unsubscribe message

Description
This command is used to set one topic for unsubscribing. You would set this command repeatedly
for more than one unsubscribing topic.
SIM PIN References

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 18 2017-09-20


Smart Machine Smart Decision

YES Vendor

Syntax

Test Command Responses


AT+CMQTTUNSUBTOPIC +CMQTTUNSUBTOPIC:
=? (0-<max_client_index>),(1-<max_unsubtopic_len>)

E
OK

L
Read Command Responses

FI
AT+CMQTTUNSUBTOPIC OK
?

AL
Write Command Responses
AT+CMQTTUNSUBTOPIC OK
=<client_index>,<reqLength

TI
><CR>data for send +CMQTTUNSUBTOPIC: <client_index>,<result>
+CMQTTUNSUBTOPIC: <client_index>,<result>

ERROR
EN
D
Defined values
FI

<client_index>
N

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


<max_client_index>
O

a numeric parameter that identifies the max client index.


<reqLength>
C

The input length of unsubscribe message. The range is from 1 to 1024.


<max_unsubtopic_len>
The max input length of unsubscribe message.
M

<result>
Refer to “Return code” chapter.
O
C

Examples
M

AT+CMQTTUNSUBTOPIC=0,11
>
SI

2.16 AT+CMQTTUNSUB Send UNSUBSCRIBE message to server

Description

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 19 2017-09-20


Smart Machine Smart Decision

This command is used to unsubscribe topic for the client.

SIM PIN References


YES Vendor

Syntax

E
Test Command Responses
AT+CMQTTUNSUB=? +CMQTTUNSUB:

L
(0-<max_client_index>),(1-<max_unsubtopic_len>),(0-1)

FI
OK

AL
Read Command Responses
AT+CMQTTUNSUB? OK

TI
Write Command Responses
/*unsubcribe one topic*/ OK
AT+CMQTTUNSUB=<clien
t_index>,<reqLength>[,<dup
>]<CR>data for send
EN
+CMQTTUNSUB: <client_index>,<result>
+CMQTTUNSUB: <client_index>,<result>
D
/*unsubcribe one or more ERROR
FI

topics which be set by


AT+CMQTTUNSUBTOPIC*
N

/
AT+CMQTTUNSUB=<clien
O

t_index>[,<dup>]
C

Defined values
<client_index>
M

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


<max_client_index>
O

a numeric parameter that identifies the max client index.


C

<reqLength>
The input length of unsubscribe message. The range is from 1 to 1024.
M

<max_unsubtopic_len>
The max input length of unsubscribe message.
SI

< 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.
<result>
Refer to “Return code” chapter.

Examples
SIM7500_SIM7600 Series_MQTT_ATC_V1.01 20 2017-09-20
Smart Machine Smart Decision

AT+CMQTTUNSUB=0,11,0
>
AT+CMQTTUNSUB=0
OK

+CMQTTUNSUB: 0,0

E
2.17 MQTT URC

L
FI
2.17.1 Disconnect passively

AL
Grammar Description
+CMQTTCONNLOST: When client disconnect passively,
<client_index>,<cause><CR><LF> URC “+CMQTTCONNLOST” will be

TI
reported, then user need to connect

Defined values
EN MQTT server again.
D
<client_index>
FI

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


<cause>
N

The cause of disconnection.


1 – socket is closed passively.
O

2 – socket is reset.
3 – network is closed.
C
M

Receive topic published by MQTT server


O

2.17.2
C

Grammar Description
M

/* If a client subscribes to one or more topics, any If a client subscribes to one or


message published to those topics are sent by the server more topics, any message published to
SI

to the client */ those topics are sent by the server to


<CR><LF>+CMQTTRXSTART: the client. The following URC is used
<client_index>,<topic_total_len>,<payload_total_len> for transmitting the message published
<CR><LF> from server to client.
<CR><LF>+CMQTTRXTOPIC: 1) +CMQTTRXSTART:
<client_index>,<sub_topic_len><CR><LF><sub_topic <client_index>,<topic_total_len>,<pa
> yload_total_len>

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 21 2017-09-20


Smart Machine Smart Decision

/*for long topic, split to multiple packets to report*/ At the beginning of receiving
[<CR><LF>+CMQTTRXTOPIC: published message, the module will
<client_index>,<sub_topic_len><CR><LF><sub_topic send this command to user, and
>] indicate client index with
<CR><LF>+CMQTTRXPAYLOAD: <client_index>, the topic total length
<client_index>,<sub_payload_len><CR><LF><sub_pa with <topic_total_len> and the
yload> payload total length with

E
/*for long payload, split to multiple packets to report*/ <payload_total_len>.
[<CR><LF>+CMQTTRXPAYLOAD: 2) +CMQTTRXTOPIC:

L
<client_index>,<sub_payload_len><CR><LF><sub_pa <client_index>,<sub_topic_len>\r\n<s

FI
yload>] ub_topic>
<CR><LF>+CMQTTRXEND: <client_index> After the command
“+CMQTTRXSTART” received, the

AL
module will send second command to
user, and indicate client index with

TI
<client_index>, the topic packet length
with <sub_topic_len> and the topic

EN content with <sub_topic> after “\r\n”.


For long topic, it will be split to
multiple packets to report and the
D
command “+CMQTTRXTOPIC” will
be send more than once with the rest
FI

of topic content. The sum of


<sub_topic_len> is equal to
N

<topic_total_len>.
O

3) +CMQTTRXPAYLOAD:
<client_index>,<sub_payload_len>\r\n
C

<sub_payload>
After the command
“+CMQTTRXTOPIC” received, the
M

module will send third command to


user, and indicate client index with
O

<client_index>, the payload packet


length with <sub_payload_len> and
C

the payload content with


M

<sub_payload> after “\r\n”.


For long payload, the same as
SI

“+CMQTTRXTOPIC”.
4) +CMQTTRXEND:
<client_index>
At last, the module will send fourth
command to user and indicate the
topic and payload have been
transmitted completely.

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 22 2017-09-20


Smart Machine Smart Decision

Defined values
<client_index>
a numeric parameter that identifies a client. The range of permitted values is 0 to 1.
<topic_total_len>
The length of topic from MQTT server to client. The range is from 1 to 1024.
<payload_total_len>
the payload total length. The range is from 1 to 10240.

E
<sub_topic_len>
the topic packet length, The sum of <sub_topic_len> is equal to <topic_total_len>.

L
<sub_topic>

FI
the topic content.
<sub_payload_len>

AL
the payload packet length. The sum of <sub_payload_len> is equal to <topic_payload_len>.
<sub_payload>
the payload content.

TI
Examples
AT+CMQTTSUB=0,13,1
>MQTT Examples
EN
D
OK
FI

+CMQTTSUB: 0,0
N

+CMQTTRXSTART: 1, 13, 12
O

+CMQTTRXTOPIC: 1, 13
MQTT Examples
C

+CMQTTRXPAYLOAD: 1, 12
Hello World!
+CMQTTRXEND: 1
M

2.18 Return code


O

< result >


C

The result of cmd.


M

0 – successful.
1 – failed.
SI

2 – bad UTF-8 string.


3 – sock connect fail.
4 – sock create fail.
5 – sock close fail.
6 – message receive fail.
7 – network open fail.
8 – network close fail.

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 23 2017-09-20


Smart Machine Smart Decision

9 – network not opened.


10 – client index error.
11 – no connection.
12 – invalid parameter.
13 – not supported operation.
14 – client is busy.
15 – require connection fail.
16 – sock sending fail.

E
17 – timeout.

L
18 – topic is empty.

FI
19 – client is used.
20 – client not acquire resource.
21 – client not release.

AL
22 – length out of range.
23 – network is opened.

TI
24 – packet fail.
25 – DNS error.
26 – socket is closed by server.
EN
27 – connection refused: unaccepted protocol version.
28 – connection refused: identifier rejected.
D
29 – connection refused: server unavailable.
30 – connection refused: bad user name or password.
FI

31 – connection refused: not authorized.


N

3 Examples
O
C

Example: connect
AT+CMQTTSTART
OK
M

+CMQTTSTART: 0
O

AT+CMQTTACCQ=0,"client c"
OK
C

AT+CMQTTCONNECT=0,"tcp://116.247.119.165:5141",20,1
M

OK
SI

+CMQTTCONNECT: 0,0
AT+CMQTTDISC=0,120
OK

+CMQTTDISC: 0,0
AT+CMQTTREL=0

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 24 2017-09-20


Smart Machine Smart Decision

OK
AT+CMQTTSTOP
+CMQTTSTOP: 0

OK
Example: connect with will topic
AT+CMQTTSTART
OK

L E
+CMQTTSTART: 0

FI
AT+CMQTTACCQ=0,"client c"
OK
AT+CMQTTWILLTOPIC=0,10

AL
>will topic
OK

TI
AT+CMQTTWILLMSG=0,56,1
>you’d better set will topic before setting will message.
OK
EN
AT+CMQTTCONNECT=0,"tcp://116.247.119.165:5141",20,1,”username”,”password”
OK
D
+CMQTTCONNECT: 0,0
FI

AT+CMQTTDISC=0,120
OK
N
O

+CMQTTDISC: 0,0
AT+CMQTTREL=0
C

OK
AT+CMQTTSTOP
+CMQTTSTOP: 0
M

OK
O

Example: publish topic


AT+CMQTTSTART
C

OK
M

+CMQTTSTART: 0
SI

AT+CMQTTACCQ=0,"client c"
OK
AT+CMQTTWILLTOPIC=0,10
>will topic
OK
AT+CMQTTWILLMSG=0,56,1
>you’d better set will topic before setting will message.

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 25 2017-09-20


Smart Machine Smart Decision

OK
AT+CMQTTCONNECT=0,"tcp://116.247.119.165:5141",20,1,”username”,”password”
OK

+CMQTTCONNECT: 0,0
AT+CMQTTPUBTOPIC=0,13
>publish topic

E
OK

L
AT+CMQTTPUBMSG=0,62

FI
>you’d better set publish topic before setting publish message.
OK
AT+CMQTTPUB=0,1,60

AL
OK

TI
+CMQTTPUB: 0,0
AT+CMQTTDISC=0,60
OK

+CMQTTDISC: 0,0
EN
D
AT+CMQTTREL=0
OK
FI

AT+CMQTTSTOP
+CMQTTSTOP: 0
N
O

OK
Example: subscribe and unsubscribe
C

AT+CMQTTSTART
OK

+CMQTTSTART: 0
M

AT+CMQTTACCQ=0,"client c"
O

OK
AT+CMQTTWILLTOPIC=0,10
C

>will topic
OK
M

AT+CMQTTWILLMSG=0,56,1
SI

>you’d better set will topic before setting will message.


OK
AT+CMQTTCONNECT=0,"tcp://116.247.119.165:5141",20,1,”username”,”password”
OK

+CMQTTCONNECT: 0,0
AT+CMQTTSUB=0,9,1,1

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 26 2017-09-20


Smart Machine Smart Decision

>subscribe
OK

+CMQTTSUB: 0,0
AT+CMQTTUNSUB=0,9,1
>subscribe
OK

E
+CMQTTUNSUB: 0,0

L
AT+CMQTTDISC=0,60

FI
OK

+CMQTTDISC: 0,0

AL
AT+CMQTTREL=0
OK

TI
AT+CMQTTSTOP
+CMQTTSTOP: 0

OK
Example: receive publish message
EN
D
+CMQTTRXSTART: 0,9,6
+CMQTTRXTOPIC: 0,9
FI

ttttttttt
+CMQTTRXPAYLOAD: 0,6
N

yyyyyy
O

+CMQTTRXEND: 0
C
M
O
C
M
SI

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 27 2017-09-20


Smart Machine Smart Decision

Contact us:
Shanghai SIMCom Wireless Solutions Ltd.
Add: Building A, SIM Technology Building, No.633, Jinzhong Road, Changning
District
200335
Tel: +86 21 3252 3300
Fax: +86 21 3252 3301
URL: http:/www.sim.com/wm/

L E
FI
AL
TI
EN
D
FI
N
O
C
M
O
C
M
SI

SIM7500_SIM7600 Series_MQTT_ATC_V1.01 28 2017-09-20

You might also like