Through this API the device can send unstructured IoT information to be processed & collected by the platform.
JSON Objects
Attribute | Description |
---|---|
version |
indicates the version of the structure |
device (optional) |
Device Identifier in case of be different that the device Identifier that sends information (included in the URI) |
path (optional) |
Identifier of the gateway or gateways that as been used by the asset for sending the information |
trustedBoot (optional)++ |
In this case you are indicating that is required a validation type trusted_boot, it’s not necessary introduce the field value but if you introduce it all the message received by the platform will compare the trustedBoot value with the provisioned value if are diferent the message will not be collected |
datastreams[] |
Array of datastreams to be collected. See Datastream object definition |
Attribute | Description |
---|---|
id |
Identifier of the datastream |
feed (optional) |
Feed Identifier |
datapoints[] |
Array of datapoints data to be collected. See Datapoint object definition |
The feeds concept in the JSON object can be used to differentiate:
If no multiples feeds are needed the name "default" of the feed must be used as feed to collect information from sensor |
Attribute | Description | ||
---|---|---|---|
from (optional) |
Number with the time in miliseconds from epoch of the start period of measurement. This indicates that value is the same within this time interval (from -→ at).
|
||
at (optional) |
If this field is missing, the platform will assign the server current time to the datapoint whe data is received.
|
||
value |
This is a polyvalent field that can be any of the JSON supported data types:
"value" : 10
"value" : "string value"
"value" : true
"value" : [ "text1", "text2" ]
"value" : { "field1": "text", "field2": 12 }
"value" : null
|
||
tags[] (optional) |
Array of tags (in string format) to be associated to a datapoint |
Collecting information
POST /south/v80/devices/{device.id}/collect/iot
This request allows the device to append or modify information to an existing datastream.
It can be done:
-
Writing datapoints with their respective timestamps in different datastreams in a only request
-
Writing datapoints without timestamp in different datastreams in a only request
The second request type is used when the device hasn’t internal clock. In this case the platform connector puts the associated timestam. It is mainly used to provide latest value of a signal in the sensor or the machine |
Using curl to perform the request:
curl --request POST \ --data-binary @datapoints.json \ --header "X-ApiKey: YOUR_API_KEY_HERE" \ --verbose \ http://[your_opengate_address]/south/v80/devices/{device.id}/collect/iot \ -H "Content-type: application/json"
In the response we should see a status code of 200 (created). Let’s look the response.
HTTP/1.1 201 Added
JSON Examples
Let’s see some examples:
{ "version":"1.0.0", "datastreams" : [ { "id" : "example", "feed" : "feed_1", "datapoints":[ {"at":1431602523123,"value":41}, {"at":1431602623123,"value":84}, {"at":1431607623123,"value":41}, {"at":1431608623123,"value":83} ] }, { "id" : "key", "feed" : "feed_2", "datapoints":[ {"at":1431602523123,"value":"revalue"}, {"at":1431602623123,"value":"string value"}, {"at":1431607623123,"value":"any string"}, {"at":1431608623123,"value":"structured data"} ] }, { "id" : "datastream", "datapoints":[ {"at":1431602523123,"value":51, "tags":["tag_1","tag_2"]}, {"at":1431602623123,"value":102, "tags":["tag_2","tag_3"]}, {"at":1431607623123,"value":32}, {"at":1431608623123,"value":16, "tags":["tag_3"]} ] } ] }
{ "version":"1.0.0", "datastreams" : [ { "id" : "example", "feed" : "feed_1", "datapoints":[ {"value":333} ] }, { "id" : "key", "feed" : "feed_2", "datapoints":[ {"value":"value"} ] }, { "id" : "datastream", "datapoints":[ {"value":1337} ] } ] }
{ "version": "1.0.0", "device": "asset1", "path": [ "gateway1" ], "trustedBoot": "ñasdohfñasjkdfñ", "datastreams": [ { "id": "example", "datapoints": [ { "at": 1490092712000, "value": "1" } ] } ] }
To find a list of specific datastream and examples of using it see Default Datamodels |