This post shows how to use OpenGate Constrained Application Protocol - CoAP connector.
Access data
Some CoAP libraries and environments need domain name resolution. In those cases, api.opengate.es
must be previously resolved to its IP address. At the time of this document, the IP address for api.opengate.es
was 35.157.105.177
. Please check it before starting your test.
If you’re like me and are using a Linux machine, type nslookup
:
charlie@dune> nslookup api.opengate.es
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: api.opengate.es
Address: 35.157.105.177
- Host:
api.opengate.es
or35.157.105.177
(see previous warning note) - CoAP Port:
5683
- CoAP URI:
coap://35.157.105.177:5683/v80/devices/collect/iot
Custom options
OpenGate CoAP connector uses some options:
2502
: api_key2503
: device_id2504
: message_protocol_version
Payload
The payload definition in the official OpenGate documentation to publish data is entirely valid. You only have to add, at the top level of the JSON document, the following fields:
- a
"device": "your-device-id"
field, filled with the OpenGate device unique identifier. - a
"apikey": "your-api-key
field, filled with your OpenGate API key.
See the following example:
{
"version": "1.0.0",
"device": "your-device-id",
"datastreams": [
{
"id": "temperature",
"datapoints": [
{
"at": 1431602523123,
"value": 24.1
}
]
}
]
}