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

Property Delivery Usage

Property delivery is used for property modification or query. The following uses property modification as an example.

Description

Figure 1 Process of property delivery
  1. An application calls the API for modifying device properties to deliver a request to the platform. Example message:
    PUT https://{endpoint}/v5/iot/{project_id}/devices/{device_id}/properties  
    {   
        "services" : [ {     
            "service_id" : "Temperature",     
            "properties" : {
                "value" : 57     
            }  
         }, {     
            "service_id" : "Battery",     
            "properties" : { 
                "level" : 80     
            }   
        } ] 
    }
  2. The platform sends the property to the device according to the protocol specifications. The following is an example of setting properties through the APIs for MQTT devices.
    Topic: $oc/devices/{device_id}/sys/properties/set/request_id={request_id}  
    Data format:
    {
        "object_device_id": "{object_device_id} ",
        "services": [
            {
                "service_id": "Temperature",
                "properties": {
                    "value": 57,
                    "value2": 60
                }
            },
            {
                "service_id": "Battery",
                "properties": {
                    "level": 80,
                    "level2": 90
                }
            }
        ]
    }
  3. The device executes the command and returns the execution result. Example message:
    Topic: $oc/devices/{device_id}/sys/properties/set/response/request_id={request_id}
    Data format:
    {
        "result_code": 0,
        "result_desc": "success"
    }
  4. The platform synchronously sends a response to the HTTP command. Example message:
    Status Code: 200 OK
    Content-Type: application/json
    {   
        "response" : {     
            "result_code" : 0,     
            "result_desc" : "success"   
        } 
    }