EMQPUBOPEN – create a publish message topic
Create and view publish message topics. Use these topics to publish data to things in the cloud.
The topic name depends on the MQTT parameter unless you use a token. See Using the AnyNet SMARTconnect™ configuration file.
You can use the following tokens to construct the topic name:
$t— Returns the cloudthingName.$i— Returns the device International Mobile Equipment Identity (IMEI).
For example, status/$i publishes as status/.
You can only include one token in a topic.
Test
AT+EMQPUBOPEN=?
+EMQPUBOPEN: (0-7) and OK
Read
AT+EMQPUBOPEN?
A list of publish topics and OK
Write
AT+EMQPUBOPEN=(0-7),"/[$t | $i]"
Creates or updates a publish topic
The Read command returns topics in this format:
0: /<[mqtt] topicsuffix>
1: /<[mqtt] topicsuffix>
OKThe returned topic list includes:
An index number, starting at
0.The unique publish topic name for the index.
The appended
topicsuffixpath.
topicsuffix can include $i for the IMEI or $t for the cloud thingName. The maximum $t length is 128 characters for AWS and 255 characters for Google. The complete topic must not exceed the MQTT broker limit of 256 characters. The Quectel module does not return empty topics.
For the Write command:
Set the publish index from
0through7.Set a publish topic title up to
256characters, including/cloudThingNameor/IMEI.Do not use special characters in a topic title.
Optionally include
$tor$i.
Examples
Create a topic with the IMEI token:
Create a topic without a token:
List publish topics:
Publish a JSON message:
In the last example, the MQTT broker receives:
For useful AWS information regarding maximum lengths, see: AWS IoT Core endpoints and quotas.
Last updated
Was this helpful?