A Message Queuing Telemetry Transport (MQTT) gateway device can communicate with IoT Platform by using a custom topic. IoT Platform can pass through the upstream and downstream communication data of the device. This topic describes how to implement upstream and downstream communication between a device and IoT Platform.

Topics

IoT Platform can communicate with gateway devices by using topics over MQTT. You must define custom topics for communication. The topics for communication must comply with the topic specifications that are defined in the standard MQTT protocol. For more information about topics, see Topics.

You can use the topic that is used by a device to submit data as a custom topic. The topic that is used by a device to send upstream data is the same as the topic that is used by the device to receive downstream data.

The following table describes the differences between topics supported by IoT Platform and topics supported by the standard MQTT protocol.

ItemIoT PlatformStandard MQTT protocol
LengthThe topic must be 1 to 128 characters in length. The topic can be up to 65,535 characters in length.
Character setThe topic can contain only letters, digits, and underscores (_). The topic can contain UTF-8 characters. No other limits exist.

Limits

  • An MQTT gateway device can subscribe to up to 100 topics.
  • If you set the Device Operation Authorizations parameter of a topic category to Subscribe, you can specify the plus sign (+) and number sign (#) wildcard characters in the topic category to allow devices to subscribe to multiple topics at the same time. For more information about how to use wildcard characters, see Custom topics with one or more wildcard characters.

Upstream communication: devices to IoT Platform

A device publishes messages to a custom topic. IoT Platform can receive messages from the device by using an Advanced Message Queuing Protocol (AMQP) server-side subscription or the data forwarding feature.

When you configure data forwarding rules, take note of the following items:

  • You can use only the new version of the data forwarding feature to configure data forwarding rules for gateway devices. For more information, see Configure a data forwarding parser.
  • You cannot forward messages from IoT Platform gateway products and devices to IoT Platform common products and devices. You also cannot forward messages from IoT Platform common products and devices to IoT Platform gateway products and devices.
  • When you forward the data of a gateway device to another topic, you must configure the deviceName parameter. For more information, see Forward data to destinations.
  • If you want to specify a source topic from which data is forwarded, you must enter the name of the topic. For more information, see Create a data source.
  • You can use server-side subscriptions to push data of only the Device Upstream Notification, Device Status Change Notification, and Device Changes Throughout Lifecycle types. For more information, see Configure an AMQP server-side subscription.

Downstream communication: IoT Platform to devices

IoT Platform calls the Pub API operation to publish messages to a specified custom topic. Devices receive messages from IoT Platform by subscribing to the topic.