Loading...
Searching...
No Matches
CoAP Resource Declarations

Declare CoAP resources at compile time. More...

Detailed Description

Declare CoAP resources at compile time.

Module. Specify USEMODULE += unicoap_server_resource_declarations in your application's Makefile.

Use UNICOAP_RESOURCE to define resources across files as follows. The name you supply for the resource must be unique among resource definitions but has otherwise no meaning. It is needed purely for technical reasons involving the implementation of cross file arrays. The resource macro must be followed by a constant unicoap_resource_t initializer. In the example below, we define a resource reachable under /hello-world using the designated initializer.

UNICOAP_RESOURCE(hello_world_resource) {
.path = UNICOAP_PATH("hello-world"),
.handler = my_hello_world_handler,
};
@ UNICOAP_METHOD_GET
GET request (no paylod)
Definition constants.h:140
#define UNICOAP_RESOURCE(name)
Declares a static CoAP resource.
Definition server.h:773
#define UNICOAP_METHODS(first_method,...)
Macro that builds a bit field where the i-th bit indicates the i-th request method 0....
Definition server.h:691
#define UNICOAP_PATH(...)
Constructs a path.
Definition server.h:90

Declaring a CoAP resource at compile time

#define UNICOAP_RESOURCE(name)
 Declares a static CoAP resource.
 

Macro Definition Documentation

◆ UNICOAP_RESOURCE

#define UNICOAP_RESOURCE ( name)
Value:
XFA_CONST(unicoap_resource_t, unicoap_resources_xfa, 0) CONCAT(unicoap_resource_, name) =
#define CONCAT(a, b)
Concatenate the tokens a and b with expansion.
Definition utils.h:30
struct unicoap_resource unicoap_resource_t
CoAP resource.
Definition server.h:202
#define XFA_CONST(type, xfa_name, prio)
Define variable in read-only cross-file array.
Definition xfa.h:156

Declares a static CoAP resource.

Parameters
nameInternal name of the resource entry, must be unique

Places resource definition in cross-file array (XFA) of resources read upon initialization.

You must supply a constant initializer following the macro invocation. The name you supply is needed for technical reasons but has otherwise no meaning.

Definition at line 773 of file server.h.