Skip to content
MonsterCode8000 edited this page Jan 8, 2016 · 7 revisions

CoAP with C using libcoap!

libcoap is a CoAP implementation in C. Some information can be found on the homepage, but the code is hosted on github.

There may be some dependencies you need to install using your preferred package manager, such as sudo apt-get install autoconf automake libtool.

Get the code with git clone https://github.com/obgm/libcoap.git than make cd libcoab and use the autogen.sh script provided in the develop branch. Next, execute the configure script with the --no-documentation or --disable-documentation argument (the documentation requires a2x which wasn't available on my system).

Next you can build the library (make) and install it (sudo make install). The header files will be installed to /usr/local/include/coap and the library to /usr/local/lib/libcoap-1.a (note, that the name is not just libcoap) and needs to be linked accordingly.

Copy the examples folder to a different location to use it as a basis and cd into it. Then, the client can be build using gcc -I /usr/local/include/coap client.c coap_list.c -o client -lcoap-1 -DWITH_POSIX. Note the flag -DWITH_POSIX at the end which is required on Linux, but may differ for a different OS, such as Contiki.

TL;DR

sudo apt-get install autoconf automake libtool
git clone https://github.com/obgm/libcoap.git
cd libcoap
./autogen.sh
./configure --no-documentation
make
sudo make install
Clone this wiki locally