-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
nanocoap and gcoap's APIs, particularly for CoAP Option handling, have developed as needed. Recently #8772 reworked how options are referenced in the coap_pkt_t struct for scalability. In addition the number of Option API functions has grown to the point where they make up a significant portion of the overall API. This issue describes how we plan to update the APIs to accommodate these changes.
#9085 introduced a more convenient, struct-based API for writing CoAP Options. It also introduced a more structured naming scheme to manage the large number of convenience functions for these options, for example in #8920 for string-based options.
The struct-based API also brings the nanocoap and gcoap APIs much closer together. In fact the gcoap API becomes mostly convenience/sugar on the struct-based API. See API Options for details.
The table below shows the steps to fully incorporate the struct-based Options API. See the project page for implementation status.
Subject | Library | Description |
---|---|---|
API definition and 'add' functions | nanocoap | Use a coap_pkt_t when build a message and add coap_opt_add_xxx() functions. |
'add' option functions | gcoap | Use coap_opt_add_xxx() functions within gcoap |
uint option functions | nanocoap | Create coap_opt_add_xxx() , coap_opt_put_xxx() , and coap_get_xxx() functions for uint-based options, like Content-Format |
string option functions | nanocoap | Create coap_opt_add_xxx() , coap_opt_put_xxx() , and coap_get_xxx() functions for string-based options, like Uri-Path and Uri-Query; adapt #8920 |
module level documentation | nanocoap | Document the API and provide direction on how to use it. See doc page for the concept. |
API update for 'finish' functions | gcoap | Deprecate use of gcoap_finish() after payload is written, in favor of coap_opt_finish() before payload is written. Simplifies implementation and removes gcoap-specific code. |