Connect any device over CoAP

CoAP Basics #

CoAP is a light-weight IoT protocol for constrained devices. CoAP protocol is UDP based, but similar to HTTP it uses request-response model. CoAP observes option allows to subscribe to resources and receive notifications on resource change.

Controllino Cloud server nodes act as a CoAP Server that supports both regular and observe requests.

Client libraries setup #

You can find CoAP client libraries for different programming languages on the web. Examples in this article will be based on CoAP CLI.

NOTE: CoAP cli does not support query parameters. If you require to use query parameters, you should use CoAP Client instead. To install the coap-client please execute:

Ubuntu 20.04: sudo apt install libcoap2-bin
Ubuntu 18.04: sudo apt install libcoap1-bin

CoAP Authentication and error codes #

We will use access token device credentials in this article and they will be referred to later as $ACCESS_TOKEN. The application needs to include $ACCESS_TOKEN as a path parameter into each CoAP request. Possible error codes and their reasons are:

4.00 Bad Request - Invalid URL, request parameters or body.
4.01 Unauthorized - Invalid $ACCESS_TOKEN.
4.04 Not Found - Resource not found.