Professional Documents
Culture Documents
Neoway NB-IoT MQTT Application Guide V1.0 PDF
Neoway NB-IoT MQTT Application Guide V1.0 PDF
Date 2018-12-17
Notice
This document provides guide for users to use NB-IoT Modules.
This document is intended for system engineers (SEs), development engineers, and test engineers.
Neoway provides customers complete technical support. If you have any question, please contact your
account manager or email to the following email addresses:
Sales@neoway.com
Support@neoway.com
Website: http://www.neoway.com
Contents
1 Overview.................................................................................................... 1
2 Initialization Process .................................................................................. 2
3 MQTT Service ........................................................................................... 3
3.1 Process ........................................................................................................................................ 3
3.2 Example ....................................................................................................................................... 4
Scope
This document is applicable to NB-IoT Modules.
Audience
This document is intended for system engineers (SEs), development engineers, and test engineers.
Change History
Issue Date Change Changed By
Conventions
Symbol Indication
This warning symbol means danger. You are in a situation that could cause fatal
device damage or even bodily damage.
Means reader be careful. In this situation, you might perform an action that
could result in module or product damages.
1 Overview
This document describes how to use the MQTT functions of Neoway NB-IoT modules and their AT
command processes.
2 Initialization Process
To use the MQTT function after the modules is powered up and started, ensure that the module is
initialized and registers with a network.
Send AT
N
If UART returns OK, it is ready.
Receive "OK"? If UART does not return code, keep sending AT every second for 10 times.
If UART does not return code after 10 times, restart the module.
Send AT+CEREG?
If the module returns +CEREG: 0,1 or +CEREG: 0,5, it registers with PS domain.
+CEREG: 0,1 If the module returns +CEREG:0,<0,2,3,4>, it does not register with the PS
or domain. Send the command every second for 40 times.
+CEREG: 0,5 If the module cannot register network after querying for 40 times, restart the
module.
3 MQTT Service
This chapter describes the process of MQTT service and provides an example.
3.1 Process
Figure 3-1 Flowchart of MQTT service
2. Obtain IP address
AT+XIIC=1
N
Return OK?
Y
3. Query IP address
AT+XIIC? If UART returns +XIIC:1,<IP>, the module obtains the IP address.
If UART returns +XIIC: 0 ,0.0.0.0, the module does not obtain the IP
N N address. Query the IP address every second for 20 times.
Return to +XIIC: 1, IP
step 1 If the query fails for 20 times, check the signal strength, network, and
Y registration status and obtain the IP address again.
If the module fails to obtain IP address for 3 times, restart the module.
4. Set user parameters
AT+MQTTCONNPARAM=<clientID>,<usernam
e>,<password>
Return OK?
N
Y
5. Set up a MQTT connection
Recommended timeout interval is 30 seconds.
AT+MQTTCONN=<host>,<clean>,<keep_alive>
Return OK?
N
Y
6. Subscribe a topic
AT+MQTTSUB=<topicname>,<qos>
N
Return OK?
Y
7. Publish a topic
AT+MQTTPUB=<retained>,<qos>,<topicname>
,<message>
Return OK?
N
Continue to
subscribe or Y
publish a topic
8. Query MQTT connection status
AT+MQTTSTATE?
Return to N
Return 1?
step 4
Y
9. Close the connection
AT+MQTTDISCONN
End
3.2 Example
AT //The module responds to AT properly after it is powered up.
OK
AT+CPIN?
+CPIN: READY //Check whether the module identifies the SIM card.
OK
AT+CSQ
+CSQ: 31, 99 //Check the signal quality.
OK
AT+CEREG?
+CEREG: 0,1 //Check whether the module registers with a network
successfully.
OK
AT+XIIC?
+XIIC: 1,100.79.207.128
OK