coap_init - Man Page

Work with CoAP initialization

Synopsis

#include <coap3/coap.h>

void coap_startup(void);

void coap_cleanup(void);

For specific (D)TLS library support, link with -lcoap-3-notls, -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls, -lcoap-3-wolfssl or -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default (D)TLS library support.

Description

The CoAP libcoap logic needs to be initialized before there is any use of the libcoap public API. This is done by calling coap_startup().

Functions

Function: coap_startup()

The coap_startup() function must be called before any other coap_*() functions are called. It is used to initialize things like mutexes, random number gererators, clocks, TLS libraries etc.

NOTE: This should be called after any other lower layer is initialized. For example, for LwIP, lwip_init() must be called before coap_startup().

NOTE: After the inital call to coap_startup(), subsequent calls are ignored until coap_cleanup() is called.

Function: coap_cleanup()

The coap_cleanup() function is used to cleanup / free any information set up by the coap_startup() function and should be the last coap_*() function called. The only safe function that can be called after coap_cleanup() is coap_startup() to re-initialize the libcoap logic.

NOTE: Calling coap_cleanup() in one thread while continuing to use other coap_*() function calls in a different thread is not supported - even if they are using a different coap_context_t.

NOTE: All other libcoap cleanups should called prior to coap_cleanup(), e.g. coap_free_context(3).

Further Information

See

"RFC7252: The Constrained Application Protocol (CoAP)"

for further information.

Bugs

Please raise an issue on GitHub at https://github.com/obgm/libcoap/issues to report any bugs.

Please raise a Pull Request at https://github.com/obgm/libcoap/pulls for any fixes.

Authors

The libcoap project <libcoap-developers@lists.sourceforge.net>

Referenced By

coap_block(3), coap_cache(3), coap_io(3), coap_locking(3), coap_observe(3), coap_persist(3).

The man pages coap_cleanup(3) and coap_startup(3) are aliases of coap_init(3).

09/07/2024 coap_init 4.3.5 libcoap Manual