decode API Description
The input parameter binaryData over the decode API is the payload in the CoAP message sent by a device.
Upstream packets of a device can be classified into the following types: data reported by device and responses of the device to the IoT platform (corresponding to messages 1 and 5 in the following figure). Message 4 is the protocol ACK message returned by the module. No plug-in processing is required. The decoding output fields vary depending on the upstream packet.
Field |
Type |
Description |
Mandatory or Optional |
---|---|---|---|
identifier |
String |
Specifies the identifier of the device in the application protocol. The IoT platform obtains the parameter over the decode interface, encodes the parameter over the encode interface, and places the parameter in a stream. |
Optional |
msgType |
String |
This field has a fixed value of deviceReq, which indicates that the device reports data to the IoT platform. |
Mandatory |
hasMore |
Int |
Specifies whether the device has subsequent data to report.
Subsequent data indicates that a piece of data reported by a device may be reported in multiple times. After the data is reported in the current time, the IoT platform determines whether there are subsequent messages using the hasMore field. The hasMore field is valid only in PSM mode. When the hasMore field of reported data is set to 1, the IoT platform does not deliver cached commands until it receives reported data whose hasMore field is set to 0. If the reported data does not contain the hasMore field, the IoT platform processes the data assuming that the hasMore field is set to 0. |
Optional |
data |
ArrayNode |
Specifies content of data reported by the device. For details, see Table 2. |
Mandatory |
Field |
Type |
Description |
Mandatory or Optional |
---|---|---|---|
serviceId |
String |
Identifies a service. |
Mandatory |
serviceData |
ObjectNode |
Specifies the data of a service. Detailed fields are defined in the profile file. |
Mandatory |
eventTime |
String |
Specifies the data collection time, which is in the format of yyyyMMddTHHmmssZ, for example, 20161219T114920Z. |
Optional |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{
"identifier":"123",
"msgType":"deviceReq",
"hasMore":0,
"data": [{"serviceId":"NBWaterMeterCommon",
"serviceData":{
"meterId":"xxxx",
"dailyActivityTime":120,
"flow": "565656",
"cellId":"5656",
"signalStrength":"99",
"batteryVoltage":"3.5"
}
"eventTime":"20160503T121540Z"} ,
{"serviceId":"waterMeter",
"serviceData":{"internalTemperature":256},
"eventTime":"20160503T121540Z"}
]
}
}
|
Field |
Type |
Description |
Mandatory or Optional |
---|---|---|---|
identifier |
String |
Specifies the identifier of the device in the application protocol. The IoT platform obtains the parameter over the decode API, encodes the parameter over the encode API, and places the parameter in a stream. |
Optional |
msgType |
String |
This field has a fixed value of deviceRsp, which indicates that the IoT platform sends a response to the device. |
Mandatory |
mid |
Int |
Specifies a 2-byte unsigned command ID. If the device must return the command execution result (deviceRsp), this field is used to associate the command execution result (deviceRsp) with the corresponding command. When the IoT platform delivers a command over the encode API, the IoT platform places the MID allocated by the IoT platform into a stream and delivers the stream to the device together with the command. When the device reports the command execution result (deviceRsp), the device returns the MID to the IoT platform. Otherwise, the IoT platform cannot associate the delivered command with the command execution result (deviceRsp). As a result, the IoT platform cannot update the command delivery status (success or failure) based on the command execution result (deviceRsp). |
Mandatory |
errcode |
Int |
Specifies the request processing result code. The IoT platform determines the command delivery status based on this field.
|
Mandatory |
body |
ObjectNode |
Specifies the response to the command sent by the IoT platform. Detailed fields are defined in the profile file.
NOTE:
The body is not an array. |
Optional |
Example:
1 2 3 4 5 6 7 8 9 |
{
"identifier": "123",
"msgType": "deviceRsp",
"mid": 2016,
"errcode": 0,
"body": {
"result": 0
}
}
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot