Skip to content

CoAP struct-based Options API #9309

@kb2ma

Description

@kb2ma

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.

Metadata

Metadata

Assignees

Labels

Area: CoAPArea: Constrained Application Protocol implementationsArea: networkArea: NetworkingDiscussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRType: trackingThe issue tracks and organizes the sub-tasks of a larger effort

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions