Updated on 2024-12-02 GMT+08:00

Platform Delivering a Message

Function

This API is used by an application to deliver a message in custom format to a device when the application cannot deliver data in the format defined in the product model. You can also use the standard format encapsulated by the platform. That is, set payload_format to standard when using the API for message delivery on the application side. Alternatively, select by system format on the message delivery page of the device details page.

For differences between command delivery and message delivery, see Message Communications Overview.

It is not suitable to report data in JSON format for devices with low configuration and limited resources or with limits on bandwidth usage. In this case, devices can transparently transmit the original binary data to the platform, but a codec is required to convert binary data to JSON format. For details about how to develop codecs, see Developing a Codec.

Topic

Downstream: $oc/devices/{device_id}/sys/messages/down

Parameters

Table 1 Fields in the message delivered in the system format

Parameter

Mandatory/Optional

Type

Description

object_device_id

Optional

String

Explanation:

  • For directly connected device: This parameter is not carried.
  • For gateway child device: The value is the child device ID in the topic.

name

Optional

String

Explanation:

Message name, which is optional and is used for description.

id

Optional

String

Explanation:

Unique ID of a message, which is used to distinguish and search for messages. If you do not enter a value, the system automatically generates a message ID. The message ID must be unique.

content

Mandatory

String

Explanation:

Message content, which can be encoded in Base64 format.

Example

System format:

Topic: $oc/devices/{device_id}/sys/messages/down
Data format:
{
    "object_device_id": "{object_device_id}",
    "name": "name",
    "id": "id",
    "content": "hello"
}

Customized format:

Topic: $oc/devices/{device_id}/sys/messages/down
Data format:
arbitrary content