obgm/libcoap logo

obgm/libcoap

Free

A CoAP (RFC 7252) implementation in C

FreeFree tier
Type
Open Source

About obgm/libcoap

libcoap is a C implementation of the Constrained Application Protocol (CoAP) as defined in RFC 7252, designed for resource-constrained devices with limited computing power, memory, bandwidth, or network packet sizes. It includes a protocol parser, basic networking functions for platforms with malloc() and BSD-style sockets, and support for Contiki-NG, Espressif/ESP-IDF, LwIP, and RIOT-OS environments. The library implements numerous CoAP extensions including Group Communication (RFC7390), Observe (RFC7641), Block-Wise Transfers (RFC7959), No Server Response (RFC7967), PATCH and FETCH (RFC8132), CoAP over TCP/TLS/WebSockets (RFC8323), OSCORE (RFC8613), Hop-Limit (RFC8768), Extended Tokens (RFC8974), Echo and Request-Tag (RFC9175), and Block-Wise Robust Transmission (RFC9177). It supports (D)TLS security via OpenSSL, GnuTLS, and PKCS11 modules.

Key Features

Lightweight C implementation of CoAP (RFC 7252)
Supports extensive CoAP extensions: Group Communication, Observe, Block-Wise, PATCH/FETCH, TCP/TLS/WebSockets, OSCORE, Hop-Limit, Extended Tokens, Echo/Request-Tag, Block-Wise Robust Transmission
(D)TLS security with OpenSSL, GnuTLS, PKCS11, and PSK support
Cross-platform: Contiki-NG, Espressif/ESP-IDF, LwIP, RIOT-OS, BSD-socket systems
Includes protocol parser and basic networking functions
Active open-source project with 914 stars and 469 forks on GitHub
Supports Internet Draft for URI-Path abbreviation

Pros & Cons

Pros
  • Open-source under BSD license
  • Lightweight and efficient for constrained devices
  • Supports a wide range of CoAP extensions and standards
  • Provides (D)TLS security for encrypted communication
  • Portable across multiple embedded platforms
  • Actively maintained with regular updates and community support
Cons
  • Requires C programming knowledge for integration
  • Library-only, not a ready-to-use application
  • Setup and configuration may be complex for beginners
  • Limited to CoAP protocol; not suitable for RESTful HTTP applications

Best For

IoT device communication (sensors, actuators)M2M communication in constrained networksEmbedded systems requiring lightweight application protocolSmart home automationIndustrial IoT with resource-limited devices

FAQ

What is libcoap?
libcoap is a C implementation of the Constrained Application Protocol (CoAP), a lightweight application protocol for resource-constrained devices standardized by the IETF as RFC 7252.
Which platforms are supported?
libcoap supports platforms with malloc() and BSD-style sockets as well as Contiki-NG, Espressif/ESP-IDF, LwIP, and RIOT-OS environments.
Does libcoap support security?
Yes, libcoap provides (D)TLS support via OpenSSL, GnuTLS, and PKCS11 modules, supporting PKI, PSK, RPK, and PKCS11 authentication.