Friday, November 25, 2016

A CoAP server for the riot operating system using libcoap

View a list of all libcoap examples here.

The riot operating system ( is an operating system for the Internet of Things that currently supports many platforms. One of the main advantages of riot is that it supports programs and libraries written in C including libcoap.

In this github repository you will find an example of a CoAP server for the riot operating system This server implements a default resource that outputs "Hello World!".In order to test the example, download the latest version of the rios os (, create a folder inside the examples directory and copy the code from in that new directory. Then from a terminal type
$ make

If you encounter any problem, consult this riot wiki page In order to use the example you have to create a virtual interface in your linux machine. In order to do this invoke the following utility:
$ <riot directory>/dist/tools/tapsetup/tapsetup -c1

This utility will create a virtural interface and a bridge (for more information visit this wiki page After this step, from the folder where you have put the example code invoke:
$ make term

This command will execute the binary created in the previous step and soon an ipv6 address will appear in the terminal. You can now access the coap server using the libcoap coap client and the displayed ipv6 address, by invoking the following command:
$ coap-client coap://[<ipv6 address>%tapbr0]