Writing data without using token

To support WRITE commands, devices must listen or SUBSCRIBE to the following topic.

ds/$serialNumber}/request

Where $serialNumber is the identifier of the device.

  • To do WRITE from API call:
    http://clab962node02/m2m/endpoints/1201201002/device/0/battery
    {​​"resourceValue":"86"}​​
  • To do WRITE from CDP UI:
    1. Create an action for WRITE request.
    2. Enter the action name.
    3. Select the primitive Impact.DeviceFanout.
    4. Enter the resource device/0/battery with the value=30, Operation = WRITE.

The topic will include the following formatted value.

{"type":"write","correlatorid":$correlatorid,"resourcepath": $resourcepath,"value":$value}

Where:

$correlatorid is a string created by IMPACT that is used to link this request to the response.

$resourcepath is the path name of the resource.

$value is the value of the resource in string forward.

The value received in the PUBLISH message will be the value to be written.

The resource path is used by the Device to identify the data element to be written and should conform to the /object/objectInstance/resource/resourceInstanceId URI format as used when collecting data.

So that confirmation of the write request is achieved, once the PUBLISH has been received in the device, the device must PUBLISH a response in the following format, with topic:

us/$Serialnumber/response

The payload will have the following format.

{"type":"write","correlatorid":$correlatorid,"resourcepath":$resourcepath,"value":$value,"status":$status,"reason":$reason}

Where:

$correlatorid is a string received from IMPACT in the request that is used to link this request to the response.

$resourcepath is the path name of the resource.

$value is the value of the resource in received in the original write request.

$status is the result of the action. HTTP Status codes apply, “200” means a successful write.

$reason is the reason sent by the device when a problem arises.

For example:

The device sends a SUBSCRIBE for configuration changes.

Topic = ds/8800002400000/request

The server sends the following to write the value 456 to the device in a PUBLISH.

Topic = ds/8800002400000/request 
Payload = {"type":"write","correlatorid":”MDM_24_2”,"resourcepath":  “sensor/0/configuration”,"value": 456 }

The write is successful, and the device sends the following PUBLISH to acknowledge this.

Topic = us/8800002400000/response
{"type":"write","correlatorid":”MDM_24_2”,"resourcepath":  “sensor/0/configuration”, “status”:200 }

Within the device, care must be made to ensure that the device responds within a reasonable time, say 10 seconds. If this is not the case the IMPACT server will time out.