[riot-devel] CoAP

Lennart Dührsen lennart.duehrsen at fu-berlin.de
Thu Oct 29 15:19:36 CET 2015


Hi Ilias,

> To use CoAP in my R21 boards should I rite the code of socket
> programming (open a udp port ,etc) or just use the coap library and it
> takes care about the socket?

all the microcoap library does is create and parse payloads (CoAP
packets), and it let's you register callback functions for each URI.

You have to handle all the networking stuff, i.e. sending and receiving
UDP packets, yourself.

I'm currently working on the mostly absent documentation of microcoap,
you can find it in this fork:

https://github.com/i2ot/microcoap

It's not finished yet, but it might help you. For the networking stuff
on RIOT OS, check out

https://github.com/RIOT-OS/RIOT/tree/master/examples/gnrc_networking

and

https://github.com/RIOT-OS/RIOT/tree/master/examples/posix_sockets

if you haven't already done so.

The example code Baptiste pointed you to is indeed out of date, but the
CoAP parts in it are still correct and should work, so you'd just have
to change the socket calls etc.

Regarding libcoap: It's a *lot* more code than microcoap, and yes, it
does all the socket stuff for you. But its documentation, too, is pretty
much nonexistent. Also, you'd probably have to port it to RIOT first, so
I suggest you use microcoap for devices that will run RIOT OS.

If you run into problems with microcoap, feel free to send me an e-mail.

Best,
Lennart


More information about the devel mailing list