Send requests and create server resources using the Constrained Application Protocol across different transports. More...
Send requests and create server resources using the Constrained Application Protocol across different transports.
Module. Specify USEMODULE += unicoap in your application's Makefile.
unicoap is work in progress. Not all functionality is implemented in RIOT yet, however the documentation already exists. Do not expect everything to work yet.unicoap is RIOT's unified and modular framework for communication via the Constrained Application Protocol. unicoap supports different transports and several CoAP features, enabled by a layered and modular design. Support for each CoAP transport, such as UDP, is available through drivers.
unicoap aims to eventually replace GCoAP, nanoCoAP small CoAP library, and nanoCoAP Sock, in favor of a more beginner-friendly and easily extensible design.
The Constrained Application Protocol (CoAP) is a lightweight alternative to HTTP. HTTP as a general-purpose application protocol carries a significant overhead and is thus problematic for IoT networks with limited bandwidth and nodes with little memory. CoAP covers a range of features needed in the IoT, such as resource discovery, message fragmentation, and end-to-end message protection.
In your application Makefile, add
unicoap enables support for CoAP over various transport protocols. Currently, unicoap supports a CoAP over UDP Driver and CoAP over DTLS Driver. You must specify at least one driver to use networking functionality. If you just want to use message APIs, you can use the framing implementation of each driver, such as the RFC 7252 Framing submodule for the RFC 7252 PDU format. unicoap implements both a client and a server. To create a CoAP server, visit Writing a Server Application.
To configure unicoap, go to the unicoap Compile-Time Configuration. For extending unicoap, refer to Behind The Scenes of unicoap.
Topics | |
| Behind The Scenes of unicoap | |
| CoAP Server | |
| Register CoAP resources and handle requests asynchronously. | |
| Drivers | |
| Collection of transport drivers. | |
| Message APIs | |
| Transport Protocol Abstractions | |
| CoAP endpoint, resource identifiers, and schemes. | |
| unicoap Compile-Time Configuration | |
| Customize limits and capabilities of unicoap. | |
Files | |
| file | unicoap.h |
Main header for unicoap | |
| file | util_macros.h |
Utility macros for unicoap | |
Data Structures | |
| struct | unicoap_job_t |
A job that can be enqueued and executed by the unicoap message processing loop. More... | |
Managing the unicoap instance | |
| kernel_pid_t | unicoap_init (void) |
| Initializes the unicoap stack. | |
| int | unicoap_deinit (void) |
| Tears down the unicoap stack, closing the background thread. | |
| static void | unicoap_loop_run (void) |
Runs unicoap processing loop. | |
| int | unicoap_loop_enqueue (unicoap_job_t *job) |
Schedules event to be run in the internal processing loop at the next possible instance. | |
| #define | UNICOAP_JOB(func) |
| Initializes a unicoap_job_t. | |
| #define UNICOAP_JOB | ( | func | ) |
Initializes a unicoap_job_t.
| func | A function that must be of type void (unicoap_job_t* job). |
| int unicoap_deinit | ( | void | ) |
Tears down the unicoap stack, closing the background thread.
Provided CONFIG_UNICOAP_CREATE_THREAD is enabled, this function will also zombify the thread created on initialization.
-1 otherwise | kernel_pid_t unicoap_init | ( | void | ) |
Initializes the unicoap stack.
If you disable the auto_init_unicoap you will need to call this function manually. Otherwise, and provided auto_init is used, unicoap will be initialized automatically.
| int unicoap_loop_enqueue | ( | unicoap_job_t * | job | ) |
Schedules event to be run in the internal processing loop at the next possible instance.
| [in,out] | job | Job to run on unicoap message processing loop |
This function facilitates running client requests when CONFIG_UNICOAP_CREATE_THREAD is disabled.
unicoap processing loop has been started. The jobs will become eligible for execution once the loop starts running, which usually is when the unicoap thread has been created. If CONFIG_UNICOAP_CREATE_THREAD is disabled, this will be after you have called unicoap_loop_run, which blocks.
|
inlinestatic |
Runs unicoap processing loop.
This function never returns, unless explicitly instructed using unicoap_deinit.
Never returns (because event_queue_t does not allow that...)