Nabto Edge CoAP

CoAP (Constrained Application Protocol) is a protocol for request/response communication between a client and server, designed for constrained devices and hence ideal for IoT.

Nabto Edge supports CoAP using the Nabto Edge Direct protocol as transport instead of e.g. a UDP or BLE based transport as used in other implementations. This means that it is possible to develop request/response clients that interact directly and securely with remote devices using CoAP, regardless of firewall configurations at either peer.

This greatly simplifies development as you can use well-known patterns from traditional client/server HTTP REST service development. You just need to focus on the two peers, client and device - no central server application development or configuration:

On the device side, you register listeners for the different endpoints to handle, e.g. a POST handler for the /heat-pump/mode endpoint seen in the diagram.

Through the Nabto Edge Client SDK, you first connect to the remote device, transparently mediated through the Nabto Basestation servers. You then invoke a CoAP request on the connection. The request is passed on through the Nabto connection to the target endpoint which handles the request. A response is sent back to the client application. That is all there is to it - only development needed on the client and device side.

Nabto Edge CoAP supersedes the RPC implementation known from Nabto Micro; all Nabto Micro RPC scenarios are possible to implement with Nabto Edge CoAP in a simpler and more robust way at the price of a slightly higher footprint. For instance, there is no limit on request/response size with Nabto Edge CoAP as compared to Nabto Micro RPC.

Use Cases

  • Interactive control of smarthome: Enable a user to control a smarthome solution - i.e., directly interacting with e.g. a lock, alarm, light control or heating system. With the lowest possible latency, you can invoke a service directly on the device, just like if it was exposed as a traditional HTTP REST service.
  • Industrial control: Securely send control commands, query registers, change configuration etc.
  • M2M scenarios: Perform Nabto Edge CoAP requests from server side applications towards devices e.g. to retrieve data or change configuration.

If it does not make sense to expose services on your device and you need a more low-level protocol implementation or simple exchange of larger amounts of data, you can consider Nabto Edge Streams instead: This gives you a low-level socket like abstraction that exposes basic read and write operations. Or the Nabto Edge TCP Tunnel abstraction if you want to provide access to an existing TCP service on the device.

Get Started

We provide SDK level support for clients and devices to easily integrate Nabto Edge CoAP in your own solutions. See the individual SDK for your desired platform.

The Remote Control guide shows how to use Nabto Edge CoAP to implement remote control use cases with client code examples.

A simple “hello, world!” example application demonstrates Nabto Edge CoAP: See the simple_coap example and its client counterpart.

The Nabto Embedded SDK also comes with a thorough Virtual Thermostat example that demonstrates CoAP - with a commandline client available.

Also see the general embedded examples section.