Device Template
Topic Template
Currently, the device template supports to describe the device topic. The device template includes two topics by default.
Used respectively:
$iot/{deviceName}/events
Used to publish (Pub) message from device client to the cloud$iot/{deviceName}/msg
Used to subscribe (Sub) messages sent from cloud to device client
The template allows adding or deleting topics, you can operate as required.
Add Topic
Common Mode
If you need to add a custom topic, create a new template, and select [Add a Topic] after entering.
Here, to facilitate the test, we add a topic that is allowable for both publish and subscription $iot/{deviceName}/user/fortest
{deviceName}
is the variable; when using corresponding device for connection, replace it with the device name.
If the name is mydevice1
when creating a device, the device can execute subscription or release operation for $iot/mydevice1/user/fortest
topic according to the configurations.
Advanced Mode
Under such mode, attention shall be paid to the allocation of proper topics and privilege to avoid security risks. We suggest that you use the advanced mode only when you have a full understanding to MQTT protocol.
It is required to comply with the following rules: The topic cannot be started with $, with the longest definition of five layers, and the total length shall not exceed 255 characters;
You can use the wildcard character # or +, the use of which shall meet the uniform requirements of MQTT 3.1.1 standard protocol and IoT Core products System Constraint.
Example:
If you want to have the pub/sub privilege for all topics when using at the server, you can create a new template, and define its subscription and publish privilege for #
(that is, all topics). In particular, please note that the device created using this template has too high privileges. Please make sure do not disclose its key.
Delete Topic
The topic in the template is no longer used, it can be deleted.