Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
sol_coap_resource Struct Reference

Description for a CoAP resource. More...

#include <sol-coap.h>

Data Fields

uint16_t api_version
 API version. More...
 
int(* del )(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 DELETE request. More...
 
enum sol_coap_flags flags
 Bitwise OR-ed flags from sol_coap_flags, if any is necessary. More...
 
int(* get )(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 GET request. More...
 
struct sol_str_slice path []
 Path representing the resource. More...
 
int(* post )(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 POST request. More...
 
int(* put )(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 PUT request. More...
 

Detailed Description

Description for a CoAP resource.

CoAP servers will want to register resources, so that clients can act on them, by fetching their state or requesting updates to them. These resources are registered using this struct and the sol_coap_server_register_resource() function.

Examples:
/src/samples/coap/simple-server.c.

Field Documentation

uint16_t sol_coap_resource::api_version

API version.

Examples:
/src/samples/coap/simple-server.c.
int(* sol_coap_resource::del)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)

DELETE request.

Parameters
dataUser data pointer provided to sol_coap_server_register_resource().
serverThe server through which the request was made.
resourceThe resource the request mas made on.
reqPacket containing the request data. It's not safe to keep a reference to it after this function returns.
cliaddrThe source address of the request.
Returns
0 on success, -errno on failure.
enum sol_coap_flags sol_coap_resource::flags

Bitwise OR-ed flags from sol_coap_flags, if any is necessary.

int(* sol_coap_resource::get)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)

GET request.

Parameters
dataUser data pointer provided to sol_coap_server_register_resource().
serverThe server through which the request was made.
resourceThe resource the request mas made on.
reqPacket containing the request data. It's not safe to keep a reference to it after this function returns.
cliaddrThe source address of the request.
Returns
0 on success, -errno on failure.
struct sol_str_slice sol_coap_resource::path[]

Path representing the resource.

An array of sol_str_slice, each being a component of the path without any separators. Last slice should be empty.

Examples:
/src/samples/coap/simple-server.c.

Referenced by light_resource_to_rep().

int(* sol_coap_resource::post)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)

POST request.

Parameters
dataUser data pointer provided to sol_coap_server_register_resource().
serverThe server through which the request was made.
resourceThe resource the request mas made on.
reqPacket containing the request data. It's not safe to keep a reference to it after this function returns.
cliaddrThe source address of the request.
Returns
0 on success, -errno on failure.
int(* sol_coap_resource::put)(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)

PUT request.

Parameters
dataUser data pointer provided to sol_coap_server_register_resource().
serverThe server through which the request was made.
resourceThe resource the request mas made on.
reqPacket containing the request data. It's not safe to keep a reference to it after this function returns.
cliaddrThe source address of the request.
Returns
0 on success, -errno on failure.

The documentation for this struct was generated from the following file: