
EMQPUBLISH – publish data to a message topic
Publish data to a created message topic. Data is sent to your thing in AWS IoT Console.
Type
Syntax
Returned Result
Test
AT+EMQPUBLISH=?
OK
+EMQPUBLISH: (0-7),(0-
1),"<pubdata>"
Read
AT+EMQPUBLISH?
OK
Write
AT+EMQPUBLISH=(0-7),(0-1),<pubdata>
where:
•
(
0-7
)
is the publish index number
•
(
0-1
)
is the Quality of Service, either:
•
0
– sends the message without
guaranteeing delivery. The
message is not stored on the
sender, and is not acknowledged
•
1
– guarantees the message is
delivered at least once
•
<pubdata>
– is the published message.
If
<pubdata>
is not contained within
quotes, it is sent as text with no
modification. The maximum payload
length is 1000 characters. All characters
must be printable.
If
"<pubdata>"
is contained within
quotes, it is handled as either ASCII-hex
or text.
ETM handles
"<pubdata>"
as ASCII-hex
if it contains an even number of valid
ASCII-hex characters (
0
-
9
,
a
-
f
,
A
-
F
).
ASCII-hex is converted to binary for
transmission.
ETM handles all other data as text. For
text messages,
\
(escape characters) are
removed.
OK
– successfully wrote the command
ERROR
– the command failed. Check your
syntax, and that you have already set up the
publish topic using
at+emqpubopen?
. Also
check you have sent the
AT+ETMSTATE=startmqtt
command to
enable MQTT.
SEND OK
– send confirmation relating to
Quality of Service. This response is for:
•
QoS=0
– message is published
•
QoS=1
– MQTT broker generates a
PUBACK
to confirm receipt of the MQTT
message
SEND FAIL
- send failure for
QoS=1
only.
Example:
AT+EMQPUBLISH=1,1,"{\"BatteryPower\": \"Low\"}"
OK
SEND OK
51
Eseye-enabled Quectel BG96 module Developer Guide v1.8
MQTT telemetry AT commands