What would be the COAP protocol?

how it works

The protocol CoAP(Constrained Application Protocol) is a HTTP protocol model which is based on UDP (main feature) facing communication Machine-to-Machine (M2M) and Internet of Things (IoT). It has the distinction that it facilitates the communication device with limited processing capabilities and memory.

The COAP uses port 5683, protocol UDP.

This protocol follows a client / server model. Customers make requests to the servers, the server sends back a response. Customers can perform GET, PUT, POST and DELETE on resources, but the Guardian uses the following methods:

method Utility
GET Used to accompany the published data.
PUT Used to publish updates.

How to test ?

To run the tests you can use the application coap-cli

One of the applications that can be used for testing is used Coap coap-cli, which is an open-source application that allows such communication, both accomplished sending message and "get reading" messages sent. For installation follow the tutorial: CoAP Cli.

The application installed after just add the command coap.

Collecting device

Performing the sending of data collected

To perform the data collection should be used to URL /gcs//collect/.

The data should be sent in JSON format, with all the values that you want to store to perform the collection and validation of data / user ID.

$ coap put coap://guardiao.cl/gcs/IOTWBS/collect/IOTWBS0001 -p '{"data":{"temperature":10,"humidity":30,"luminosity":15},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}'
Parameter Meaning Value in Example
put Data submission method, using HTTP PUT. -
url Coap protocol URL, containing the prefix and device serial number. coap://guardiao.cl/gcs/IOTWBS/collect/IOTWBS0001
-p Data in JSON format to send. {"data":{"temperatura":10,"humidade":30,"luminosidade":15},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

Data sent through -p, following JSON format and requires the following data model:

Data Meaning
data Data for shipping in varied format, based on JSON standard.
auth Authentication information.
auth:apiKey Api project Key number for authentication.
auth:email The user's email registered to the project.
{"data":{"temperature":10,"humidity":30,"luminosity":15},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

How to monitor the data collected

Através do comando coap You can monitor the data being sent and places the command mode of "listening", ie perform the GET command, and monitor the data being sent.

$ coap get coap://guardiao.cl/gcs/IOTWBS/collect/IOTWBS0001 -p '{"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}' -o
Parâmetro Significado Valor no Exemplo
get Method of receiving data using HTTP GET. -
url Coap protocol URL, containing the prefix and device serial number. coap://guardiao.cl/gcs/IOTWBS/collect/IOTWBS0001
-o Enable listening mode to monitor data sent. -
-p Authentication data to enable data collection. {"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

Trigger

How to perform the trigger change

To make the change of the trigger, the URL shall be used /gcs//trigger/.

The data should be sent in JSON format with the desired state and the authentication information for sending the change.

To enable the trigger, use the following format:

$ coap put coap://guardiao.cl/gcs/IOTWBS/trigger/IOTWBS0002 -p '{"data":{“state”:”on"},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}'

To disable the trigger, simply change the state:

$ coap put coap://guardiao.cl/gcs/IOTWBS/trigger/IOTWBS0002 -p '{"data":{“state”:”off"},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}'
Parameter Meaning Value of Example
put Data submission method, using HTTP PUT. -
url Coap protocol URL, containing the prefix and device serial number. coap://guardiao.cl/gcs/IOTWBS/trigger/IOTWBS0002
-p Data in JSON format to send. {"data":{“state”:”on"},"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

Data sent through -p, following JSON format and requires the following data model:

Data Meaning
data:state The value should be sent to: "on"/"off". To enable / disable the trigger.
auth Authentication information.
auth:apiKey Api project Key number for authentication.
auth:email The user's email registered to the project.

Signing the trigger changes

Through the command coap You can monitor the data being sent and places the command mode of "listening", ie perform the GET command, and monitor the data being sent.

$ coap get coap://guardiao.cl/gcs/IOTWBS/trigger/IOTWBS0002 -p '{"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}' -o
Parameter Meaning Value of Example
get Method of receiving data using HTTP GET. -
url Coap protocol URL, containing the prefix and device serial number. coap://guardiao.cl/gcs/IOTWBS/trigger/IOTWBS0002
-o Enable listening mode to monitor data sent. -
-p Authentication data to enable data collection. {"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

Actuators

Just following changes

To accomplish the change tracking data, and in the case of the actuator, just listen to the changes, it should be used to URL /gcs//actuator/.

The data should be ordered in JSON format containing only the validation / user ID.

$ coap get coap://guardiao.cl/gcs/IOTWBS/actuator/IOTWBS0003 -p '{"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}' -o
Parameter Meaning Value of Example
get Method of receiving data using HTTP GET. -
url Coap protocol URL, containing the prefix and device serial number. coap://guardiao.cl/gcs/IOTWBS/actuator/IOTWBS0003
-o Enable listening mode to monitor data sent. -
-p Authentication data to enable data collection. {"auth":{"apiKey":"497aa991-d8e6-4bb6-ad17-f01a13648333","email":"suporte@webonesystem.com.br"}}

Data sent through the -p, following JSON format and requires the following data model:

Data Meaning
auth Authentication information.
auth:apiKey Api project Key number for authentication.
auth:email The user's email registered to the project.