Reporting Device Measurement Points in Batch


The device measurement points are reported in batch in the following scenarios:

  • A gateway device reports the measurement point data of its sub-devices.

  • A device that is directly connected to EnOS reports measurement points with different timestamps.

  • Both scenarios mentioned above.

Note

Configure the following parameters according to the parameters defined in the model. If part of the data fails to be reported, the entire request will fail, and the first return code that occurs will be returned.


Upstream

  • Request TOPIC: /sys/{productKey}/{deviceKey}/thing/measurepoint/post/batch

  • Reply TOPIC: /sys/{productKey}/{deviceKey}/thing/measurepoint/post/batch_reply

Sample Request Format

{
    "id": "123",
    "version": "1.0",
    "params": [{
            "productKey": "product1",
            "deviceKey": "device1",
            "measurepoints": {
                "Power": {
                    "value": 1.0,
                    "quality": 9
                },
                "temp": 1.02,
                "branchCurr": [
                    "1.02", "2.02", "7.93"
                ]
            },
            "time": 123456
        },
        {
            "productKey": "product1",
            "deviceKey": "device1",
            "measurepoints": {
                "Power": {
                    "value": 2.0,
                    "quality": 9
                },
                "temp": 2.02,
                "branchCurr": [
                    "2.02", "3.02", "9.93"
                ]
            },
            "time": 123567
        },
        {
            "productKey": "product2",
            "deviceKey": "device2",
            "measurepoints": {
                "Power": {
                    "value": 1.0,
                    "quality": 9
                },
                "temp": 1.02,
                "branchCurr": [
                    "1.02", "2.02", "7.93"
                ]
            },
            "time": 123456
        }
    ],
    "method": "thing.measurepoint.post.batch"
}

Sample Response Format

{
  "id": "123",
  "code": 200,
  "data": {}
}

Request Parameter Description

Parameters

Type

Mandatory/Optional

Description

id

String

Optional

The message ID. It is a reserved parameter that is reserved for future use.

version

String

Mandatory

The version of the protocol. The current version is 1.0.

params

Object

Mandatory

The parameters used for reporting the device measurement points.

productKey

String

Optional

The product key of the device. If you need to report the data of sub-devices, the product and device keys of the sub-devices are required. If the product and device keys of sub-devices are not provided, the product and device keys in the upstream request topic will be used instead.

deviceKey

String

Optional

The device key of the device. If you need to report the data of sub-devices, the product and device keys of the sub-devices are required. If the product and device keys of sub-devices are not provided, the product and device keys in the upstream request topic will be used instead.

measurepoints

Object

Mandatory

The list of the measurement points to be reported.

Power

Struct

Optional

The identifier of the measurement point that you want to report. In this example, the measurement point has the identifier Power. The value you set for the point must match the data type defined for this parameter. In this case, the data type for Power is struct, defined with 2 paramters value and quality.

value

Integer

Optional

The parameter name of the struct data type of the measurement point Power. The value you set must match the data type defined for this parameter. For example, when the data type of this parameter is set to integer in the model, the value here must be an integer.

quality

Integer

Optional

The parameter name of the struct data type of the measurement point Power. In this example, the quality parameter indicates the data quality. Similar to the above, the value you set must match the data type defined for this parameter.

temp

Integer

Optional

The identifier of the measurement point that you want to report. In this example, the measurement point has the identifier temp. Similar to the above, the value you set must match the data type defined for this parameter.

branchCurr

Array

Optional

The identifier of the measurement point that you want to report. In this example, the measurement point has the identifier branchCurr. Similar to the above, the value you set must match the data type defined for this parameter.

time

Timestamp

Optional

The timestamp of the measurement point. When not specified, the value is the server time.

method

String

Mandatory

The request method.

Response Parameter Description

Parameter

Type

Mandatory/Optional

Description

code

Integer

Mandatory

The return code. “200” indicates that the request operation is executed successfully.

data

JSON

Optional

The detailed returned information in JSON format.

Return Code

Return Code

Error Message

Explanation

1204

Model validate failed

measurepoints contains invalid fields.

1206

Measurepoint post data format error

Invalid JSON format.

1212

No sub-device permission

The sub-device is offline or is not connected to EnOS through the pre-configured gateway device.