Read Resources

In addition to reading the Device information, IMPACT IoT may need to read specific Device resource values. In such instances, IMPACT IoT sends a JSON using POST /devices.

Table 1. Read resources API format
Parameters Description
URL http://<adapter_hostname>:<port>/devices
Method POST
Content-Type application/json
Parameters

The parameters are:

  • correlatorId - Specifies a unique identification generated by IMPACT IoT to identify the command.
  • endPointClientNames - Specifies an array of Device serial numbers to read the resource values from.
  • resources - Specifies an array of Device resources on which Read operation is to be performed.
Sample Call
{
	“correlatorId”:”the correlator value”
          "read":[
                    {
                        "resources":"device/0/battery",
                        "endPointClientNames":["TTo1AZliuT"]
                     },
                     {
                        "resources":"device/0/firmware",
                        "endPointClientNames":["TTo1AZliuT","asdfgh"]
                     }
                ]
}

Response Body:

{
	“correlatorId”:”the correlator value”,
	“requestStatus”:0,
	“responseCode”:0,
            "response":[
                           {
                             "device/0/battery":90,
                             "device/0/endPointClientName":"TTo1AZliuT",
                             "device/0/firmware":"3.0"
                            },
                            {
                              "device/0/endPointClientName":"asdfgh",
                              "device/0/firmware":"3.0fw"
                            }
                ]
}
Success Code
Response Code: 200
Error Code
400 : Bad Request
401 : Unauthorized 
403 : Forbidden 
404 : Not Found 

The Adaptation Layer responds with http status OK (200) once the data is received by the Device. The response is posted asynchronously to /m2m/device. If the correlator id is available in the command then the response must have that value populated as well.

Response - Request status

requestStatus takes one of three numerical values – 0, 1 or 2. 0 for Success, 1 for Failed and 2 for Queued. Because the response is being sent asynchronously, the value ‘2’ (queued) is not required and must not be used.

Response - Request code

responseCode takes one of the following values given in the table below. Choose the response code value that closely fits the context.

When the requestStatus is 0 (success), then the responseCode will be 0 (Success). When the requestStatus is 1 (failed) then the responseCode can be any of the response code values from the table below.

Table 2. Response codes
Response code Meaning
0 Success
1 Bad request
2 Unauthorized
3 Bad option
4 Forbidden
5 Not found
6 Method not allowed
7 Not acceptable
8 Entity incomplete
9 Precondition failed
10 Entity too large
11 Unsupported content format
12 Timeout
13 Endpoint not found
14 Unauthorized endpoint