0% found this document useful (0 votes)
640 views13 pages

A76XX Series MQTT EX - Application Note - V1.00

This document provides an overview and instructions for using MQTT EX application programming interface (API) commands on SIMCom A76XX series LTE modules. It describes the purpose and functionality of five AT commands for MQTT EX: AT+CMQTTCFG to configure MQTT context, AT+CMQTTSUB to subscribe to messages, AT+CMQTTUNSUB to unsubscribe, AT+CMQTTPUB to publish messages, and AT+CMQTTDISC to disconnect. Examples are given for subscribing to and publishing messages using these AT commands.

Uploaded by

vakif.tech
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)
640 views13 pages

A76XX Series MQTT EX - Application Note - V1.00

This document provides an overview and instructions for using MQTT EX application programming interface (API) commands on SIMCom A76XX series LTE modules. It describes the purpose and functionality of five AT commands for MQTT EX: AT+CMQTTCFG to configure MQTT context, AT+CMQTTSUB to subscribe to messages, AT+CMQTTUNSUB to unsubscribe, AT+CMQTTPUB to publish messages, and AT+CMQTTDISC to disconnect. Examples are given for subscribing to and publishing messages using these AT commands.

Uploaded by

vakif.tech
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/ 13

A76XX Series_MQTT EX_

Application Note
LTE Module

SIMCom Wireless Solutions Limited


Building B, SIM Technology Building, No.633, Jinzhong Road
Changning District, Shanghai P.R. China
Tel: 86-21-31575100
[email protected]
www.simcom.com
A76XX Series_MQTT EX_Application Note_V1.00

Document Title:: A76XX Series_MQTT EX_Application Note


Version: 1.00
Date: 2023.04.27
Status: Released

GENERAL NOTES

SIMCOM OFFERS THIS INFORMATION AS A SERVICE TO ITS CUSTOMERS, TO SUPPORT


APPLICATION AND 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 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 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.

COPYRIGHT

THIS DOCUMENT CONTAINS PROPRIETARY TECHNICAL INFORMATION WHICH IS THE PROPERTY


OF SIMCOM WIRELESS SOLUTIONS LIMITED COPYING, TO OTHERS AND USING THIS DOCUMENT,
ARE FORBIDDEN WITHOUT EXPRESS AUTHORITY BY SIMCOM. OFFENDERS ARE LIABLE TO THE
PAYMENT OF INDEMNIFICATIONS. ALL RIGHTS RESERVED BY SIMCOM IN THE PROPRIETARY
TECHNICAL INFORMATION, INCLUDING BUT NOT LIMITED TO REGISTRATION GRANTING OF A
PATENT, A UTILITY MODEL OR DESIGN. ALL SPECIFICATION SUPPLIED HEREIN ARE SUBJECT TO
CHANGE WITHOUT NOTICE AT ANY TIME.

SIMCom Wireless Solutions Limited


SIMCom Headquarters Building, Building 3, No. 289 Linhong Road, Changning District, Shanghai P.R.
China
Tel: +86 21 31575100
Email: [email protected]

For more information, please visit:


https://www.simcom.com/download/list-863-en.html

For technical support, or to report documentation errors, please visit:


https://www.simcom.com/ask/ or email to: [email protected]

Copyright © 2023 SIMCom Wireless Solutions Limited All Rights Reserved.

www.simcom.com 2 / 13
A76XX Series_MQTT EX_Application Note_V1.00

About Document

Version History

Version Date Owner What is new


V1.00 2022.04.25 Nanan.zhao New version

www.simcom.com 3 / 13
A76XX Series_MQTT EX_Application Note_V1.00

Scope

Based on module AT command manual, this document will introduce MQTT EX application process.
Developers could understand and develop application quickly and efficiently based on this document.
This document applies to ASR1803S Series, ASR1603 Series, ASR1606 Series,

www.simcom.com 4 / 13
A76XX Series_MQTT EX_Application Note_V1.00

Contents

About Document .................................................................................................................... 3


Version History ...........................................................................................................................................3
Scope ......................................................................................................................................................... 4

Contents ................................................................................................................................. 5
1 Introduction ......................................................................................................................... 6
1.1 Purpose of the document .....................................................................................................................6
1.2 Related documents .............................................................................................................................. 6

2 AT Commands for MQTT EX .............................................................................................. 7


2.1 Overview of AT Commands for MQTT EX ...........................................................................................7
2.2 Detailed Description of AT Commands for MQTT EX ......................................................................... 7
2.2.1 AT+CMQTTCFG Configure the MQTT Context ............................................................... 7
2.2.2 AT+CMQTTSUB Subscribe a message to server ............................................................8
2.2.3 AT+CMQTTUNSUB Unsubscribe a message to server .................................................. 9
2.2.4 AT+CMQTTPUB Publish a message to server .............................................................. 10
2.2.5 AT+CMQTTDISC Disconnect from server ......................................................................11
2.3 Summary of result codes for MQTT EX .............................................................................................12
2.4 Example how to use MQTT EX ......................................................................................................... 12

www.simcom.com 5 / 13
A76XX Series_MQTT EX_Application Note_V1.00

1 Introduction

1.1 Purpose of the document

Based on module AT command manual, this document will introduce MQTT EX application process.
Developers could understand and develop application quickly and efficiently based on this document.

1.2 Related documents

[1] A76XX Series_AT Command Manual

www.simcom.com 6 / 13
A76XX Series_MQTT EX_Application Note_V1.00

2 AT Commands for MQTT EX

2.1 Overview of AT Commands for MQTT EX

Command Description
AT+CMQTTCFG Configure the MQTT Context
AT+CMQTTSUB Subscribe a message to server
AT+CMQTTUNSUB Unsubscribe a message to server
AT+CMQTTPUB Publish a message to server
AT+CMQTTDISC Disconnect from server

2.2 Detailed Description of AT Commands for MQTT EX

2.2.1 AT+CMQTTCFG Configure the MQTT Context

It must be called before AT+CMQTTCONNECT and after AT+CMQTTACCQ. The setting will be cleared
after AT+CMQTTREL
AT+CMQTTCFG Configure the MQTT Context

Write Command Response

AT+CMQTTCFG="argtopi OK
c",<client_index>,<arg_to
or
pic>[,<payload_len_enabl
e>] ERROR

Parameter Saving Mode -

Reference

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

<arg_topic> A numeric parameter that identifies topic set by parameters of AT


Command for SUB,UNSUB and PUB. If set to 1,the received PUB

www.simcom.com 7 / 13
A76XX Series_MQTT EX_Application Note_V1.00

message from brokers will notified as following URC +CMQTTRECV:


<client_index>,"<topic>"[,<payload_len>],"<payload>"

0 - topic input by edit mode

1 - topic input by parameter of AT Command

<payload_len_enable> A numeric parameter that identifies report payload length.

0 - notify PUB message without payload length

1 - notify PUB message with payload length

Example
AT+CMQTTSUB=0,"topic1",2
OK

+CMQTTSUB: 0,0
AT+CMQTTSUB=0,"topic1",2,1
OK

+CMQTTSUB: 0,0

2.2.2 AT+CMQTTSUB Subscribe a message to server

AT+CMQTTSUB Subscribe a message to server


Response
OK
Write Command
+CMQTTSUB: <client_index>,<err>
/* arg_topic should set to
or
1*/
+CMQTTSUB: <client_index>,<err>
AT+CMQTTSUB=<client_i
ndex>,"<topic>",<qos>[,< ERROR
dup>] or

ERROR

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

<topic> String type parameter that identifies the subscribe topic data, the
range of length is 1 to 500 bytes.

www.simcom.com 8 / 13
A76XX Series_MQTT EX_Application Note_V1.00

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


<qos>
0 – at most once
1 – at least once
2 – exactly once
The dup flag to the message. The value is 0 or 1. The default value is
<dup>
0. The flag is set when the client or server attempts to re-deliver a
message.

Example
AT+CMQTTCFG="argtopic",0,1
OK
AT+CMQTTSUB=0,"topic",1
OK

+CMQTTSUB: 0,0

2.2.3 AT+CMQTTUNSUB Unsubscribe a message to server

AT+CMQTTUNSUB Unsubscribe a message to server


Response
OK
Write Command
+CMQTTUNSUB: <client_index>,<err>
/* arg_topic should set to
or
1*/
+CMQTTUNSUB: <client_index>,<err>
AT+CMQTTUNSUB=<clie
nt_index>,"<topic>"[,<du ERROR
p>] or

ERROR

Defined Values
<client_index> A numeric parameter that identifies a client. The range of permitted
values is 0 to 1.
<topic> String type parameter that identifies the unsubscribe topic data, the
range of length is 1 to 500 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.

Example
AT+CMQTTCFG="argtopic",0,1
OK

www.simcom.com 9 / 13
A76XX Series_MQTT EX_Application Note_V1.00

AT+CMQTTUNSUB=0,"topic"
OK

+CMQTTUNSUB: 0,0

2.2.4 AT+CMQTTPUB Publish a message to server

AT+CMQTTPUB Publish a message to server


Response
OK
Write Command
+CMQTTPUB: <client_index>,<err>
/* arg_topic should set to
or
1*/
+CMQTTPUB: <client_index>,<err>
AT+CMQTTPUB=<client_i
ndex>,"<topic>",<qos>[,< ERROR
req_length>[,<ratained>]] or

ERROR

Defined Values
<client_index> A numeric parameter that identifies a client. The range of permitted
values is 0 to 1.
<topic> String type parameter that identifies the publish topic data, the range
of length is 1 to 500 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
<req_length> The length of input message data. The publish message should be
UTF-encoded string, the range of length is 0 to 10240. The default
value is 0 when not set.
<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

Example
AT+CMQTTCFG="argtopic",0,1,1
OK
AT+CMQTTSUB=0,"topic",1
OK

www.simcom.com 10 / 13
A76XX Series_MQTT EX_Application Note_V1.00

+CMQTTSUB: 0,0
AT+CMQTTPUB=0,"topic",2,10
>ssssssssss
OK

+CMQTTRECV: 0,"topic",10,"ssssssssss"

+CMQTTPUB: 0,0

2.2.5 AT+CMQTTDISC Disconnect from server

AT+CMQTTDISC Disconnect from server


Response:
Test Command +CMQTTDISC: (0-1),(0,1-180)
AT+CMQTTDISC=?
OK
Response:
+CMQTTDISC: 0,<disc_state>
Read Command
+CMQTTDISC: 1,<disc_state>
AT+CMQTTDISC?

OK
Response
1)If disconnect successfully:
+CMQTTDISC: <client_index>,0

OK
2)If disconnect successfully:
OK

Write Command +CMQTTDISC: <client_index>,0


AT+CMQTTDISC=<client_ind 3)If failed:
ex>,<timeout> OK

+CMQTTDISC: <client_index>,<err>
4)If failed:
ERROR
5)If failed:
+CMQTTDISC: <client_index>,<err>

ERROR
Parameter Saving Mode -
Max Response Time -
Reference

www.simcom.com 11 / 13
A76XX Series_MQTT EX_Application Note_V1.00

Defined Values

<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
1s to 180s. The default value is 0s (not set the timeout value).
<disc_state> 1 disconnection
0 connection

NOTE
The topic will be clean after execute AT+CMQTTPUB.

When execute AT+CMQTTCFG="argtopic",<client_index>,<arg_topic>[,<payload_len_enable>]


that <arg_topic> set to 1, if you want to stop MQTT, just to execute AT+CMQTTSTOP after execute
AT+CMQTTDISC and not need to execute AT+CMQTTREL.

2.3 Summary of result codes for MQTT EX

Unsolicited codes Description

+CMQTTRECV: when arg_topic set to 1, the publish message received from


<client_index>,"<topic>"[,<payloa brokers will be notified by CMQTTRECV.
d_len>],"<payload>"
<client_index>:

A numeric parameter that identifies a client. The range of


permitted values is 0 to 1

<topic>:

topic data of this received publish message

<payload_len>:

payload length of this received publish message, will report if


<payload_len_enable> set to 1.

2.4 Example how to use MQTT EX

AT+CMQTTSTART
OK

+CMQTTSTART: 0
AT+CMQTTACCQ=0,"a1accq",0

www.simcom.com 12 / 13
A76XX Series_MQTT EX_Application Note_V1.00

OK
AT+CMQTTCFG="argtopic",0,1,1 //using one command to subscribe, unsubscribe
OK and publish a message after using this command.
AT+CMQTTCONNECT=0,"tcp://120.27.2.154:
1883",20,1
OK

+CMQTTCONNECT: 0,0
AT+CMQTTSUB=0,"znn11",2,1 //using one command to subscribe a message
OK

+CMQTTSUB: 0,0
+CMQTTRECV: 0,"znn11",16,"one message // receive a message
come"
AT+CMQTTPUB=0,"znn11",1,10 // using one command to publish a message
>
//input message
OK

+CMQTTPUB: 0,0
AT+CMQTTUNSUB=0,"znn11",1 //using one command to unsubscribe a message
OK

+CMQTTUNSUB: 0,0
AT+CMQTTDISC=0,120 //disconnect from server
OK

+CMQTTDISC: 0,0
AT+CMQTTSTOP
OK

+CMQTTSTOP: 0

www.simcom.com 13 / 13

You might also like