Updated on 2023-10-18 GMT+08:00

Property Reporting Usage

Description

Figure 1 Process of device property reporting

  1. Product and device creation and product model definition: For details, see Creating a Product, Registering an Individual Device, and Product Model Definition.
  2. Device authentication: The platform checks whether the device has the access permission.
  3. Device property reporting: Devices report property data using protocols such as MQTT, HTTP, and LwM2M.

    Use different APIs for different protocols.

    • MQTT: Use the property reporting APIs for MQTT devices. The following is an example of reporting MQTT device property.
      Topic: $oc/devices/{device_id}/sys/properties/report
      Data format example:
      {
          "services": [
              {
                  "service_id": "Temperature",
                  "properties": {
                      "value": 57,
                      "value2": 60
                  }
              }
          ]
      }
    • HTTPS: Use the property reporting APIs for HTTP devices. To obtain access_token for HTTP devices, see Authenticating a Device. The following is an example of reporting HTTPS device property.
      POST https://{endpoint}/v5/devices/{device_id}/sys/properties/report 
      Content-Type: application/json 
      access_token: d144a524-1997-4b99-94bf-f27128da8a34  
      {
          "services": [
              {
                  "service_id": "serviceId",
                  "properties": {
                      "Height": 124,
                      "Speed": 23.24
                  }
              }
          ]
      }
    • LwM2M/CoAP: Use the property reporting APIs for devices using LwM2M over CoAP. The following is an example of property reporting for devices using LwM2M over CoAP.
      // Assume that the data content (value) reported by the device is c4 0d 5a 6e 96 0b c3 0e 2b 30 37.
       NON-2.05   MID=48590, Token=2cb6a673cba24c04, OptionSet={"Observe":22, "Content-Format":"application/octet-stream"}, c4 0d 5a 6e 96 0b c3 0e 2b 30 37

  4. The platform stores the latest data snapshot. If the reported data complies with the product model definition, log in to the IoTDA console, choose Devices > All Devices, and select a device to access its details page. The latest data snapshot is displayed on the Device Info tab page.

    Figure 2 Platform receiving and parsing the reported device properties

  5. Data forwarding: With the data forwarding function, data can be forwarded to applications or other Huawei Cloud services for storage and processing.