Data Point Topic Cluster

MQTT IoT Suite supports users to upload data to the platform and store them in the data stream-data point model (details). By data point topic cluster, a device can call the data point storage service to store data, and get data processing result notifications by subscribing to a system topic, as shown below:

Topics in a data point topic cluster are listed as follows:

System topic Purpose QoS Subscribe Publish
$sys/{pid}/{device-name}/dp/post/json Upload device data points 0/1
$sys/{pid}/{device-name}/dp/post/json/accepted The system informs that "Device Data Points Successfully Uploaded" 0
$sys/{pid}/{device-name}/dp/post/json/rejected The system informs that "Device Data Point Upload Failed" 0

Device Data Point Upload

A device can store messages by sending data points to the fixed system topic: $sys/{pid}/{device-name}/dp/post/json. In this message, the payload field data content only supports json, as shown in the example below:

{
    "id": 123,        
    "dp": {             
        "temperatrue": [{     
            "v": 30,       
            "t": 1552289676
        }],
        "power": [{     
            "v": 4.5,        
            "t": 1552289676 
        }],
        "status": [{
                "v": {
                    "color": "blue"
                },
                "t": 1552289677
            },
            {
                "v": {
                    "color": "red"
                },
                "t": 1552289678
            }
        ]
    }
}

The parameters therein are described as follows:

Parameter Type Required (Y/S) Description
id int Yes Message ID, by four-byte signed integers greater than 0.
dp object Yes Data point content in a key-value format, where key refers to data stream name and value refers to one or more data point values in a list format. In the above example, time-stamped data are uploaded to three data streams, i.e. temperatrue, power and status.
v - Yes Data point values which can be in various formats e.g. int/float/string/object.
t int No Data point timestamp, unix time, in seconds. If data are not time-stamped, the system will take the time of the data arriving at the platform as its data time.

Device data point upload supports QoS1. If publish QoS = 1, the platform returns publish ack.

Upload Result Notification via the Platform

After message processing, the platform sends an upload result notification to the device via a system topic. If the device subscribed to this topic, it can receive the message.

When the uploaded data are processed successfully,

a message is returned to: $sys/${pid}/${device-name}/dp/post/json/accepted

The data format is:

{
    "id": 123              //correspond to Message ID when data are reported
}

When uploaded data processing failed,

a message is returned to: $sys/${pid}/${device-name}/dp/post/json/rejected

If the valid id cannot be successfully parsed, the returned data are formatted as follows:

{
    "id": -1,             
    "err_code": 98,
    "err_msg":"Illegal Data"
}

If the valid id can be successfully parsed, the data returned due to an error caused by other format problems are formatted as follows:

{
    "id": 123,            
    "err_code": 98,
    "err_msg":"Illegal Data"
}

Error Codes

When uploaded data processing failed, an error code is sent as follows:

Error Codes err_code Error Message err_msg Description
98 Illegal Data Payload Format Error. Platform Parse Failed.

More help

Learn about the best practices for uploading device data points

个搜索结果,搜索内容 “

    0 个搜索结果,搜索内容 “