RIOT OS and CoAP example

5 Apr

The last two posts showed how to use networking and to setup a border router configuration. To get a bit more productive the next thing is using one board as a CoAP server that responds to requests from the host system.

At the moment RIOT OS has 4 (yes four!) different CoAP implementations: nanocoap, microcoap, gcoap and libcoap. Two of those are included in the examples as well. They differ in their implemented functions and code sizes… So there’s a tool for every use case. Sadly not DTLS out of the box.


The needed prerequisites can of course vary based on your goals. A minimal setup would be in this case:

Building the CoAP server image

Similar to the other examples to the following and flash the image to the second board:

git clone
cd RIOT/examples/microcoap_server
make BOARD=cc2538dk
   text	   data	    bss	    dec	    hex	filename
  49440	    148	  17616	  67204	  10684	RIOT/examples/microcoap_server/bin/cc2538dk/microcoap_server.elf

I’ve chosen microcoap as an example here. When the second board boots up you should see the POST and the assigned IPv6 address:

main(): This is RIOT! (Version: 2017.04-devel-611-g3af13-debian)
RIOT microcoap example application
Waiting for address autoconfiguration...
Configured network interfaces:
Iface  6   HWaddr: 9c:00  Channel: 26  Page: 0  NID: 0x23
           Long HWaddr: 00:12:4b:00:06:15:a8:6b
           TX-Power: 0dBm  State: IDLE
           AUTOACK  MTU:1280  HL:64  6LO  IPHC
           Source address length: 8
           Link type: wireless
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::212:4b00:615:a86b/64  scope: local
           inet6 addr: 2001:db8::212:4b00:615:a86b/64  scope: global

Waiting for incoming UDP packet...

Access via CoAP

Now you can either use a console based CoAP client like described here or you can use the handy Firefox Add-on Copper:

You can make a DISCOVER and then GET the description of the board you are using…