Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
coap_service.h File Reference

CoAP Service API. More...

Go to the source code of this file.

Macros

#define COAP_RESOURCE_DEFINE(_name, _service, ...)
 Define a static CoAP resource owned by the service named _service .
 
#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags)
 Define a CoAP service with static resources.
 
#define COAP_SERVICE_COUNT(_dst)   STRUCT_SECTION_COUNT(coap_service, _dst)
 Count the number of CoAP services.
 
#define COAP_SERVICE_RESOURCE_COUNT(_service)   ((_service)->res_end - (_service)->res_begin)
 Count CoAP service static resources.
 
#define COAP_SERVICE_HAS_RESOURCE(_service, _resource)    ((_service)->res_begin <= _resource && _resource < (_service)->res_end)
 Check if service has the specified resource.
 
#define COAP_SERVICE_FOREACH(_it)   STRUCT_SECTION_FOREACH(coap_service, _it)
 Iterate over all CoAP services.
 
#define COAP_RESOURCE_FOREACH(_service, _it)    STRUCT_SECTION_FOREACH_ALTERNATE(coap_resource_##_service, coap_resource, _it)
 Iterate over static CoAP resources associated with a given _service.
 
#define COAP_SERVICE_FOREACH_RESOURCE(_service, _it)
 Iterate over all static resources associated with _service .
 
CoAP Service configuration flags

#define COAP_SERVICE_AUTOSTART   BIT(0)
 Start the service on boot.
 

Functions

int coap_service_start (const struct coap_service *service)
 Start the provided service .
 
int coap_service_stop (const struct coap_service *service)
 Stop the provided service .
 
int coap_service_is_running (const struct coap_service *service)
 Query the provided service running state.
 
int coap_service_send (const struct coap_service *service, const struct coap_packet *cpkt, const struct sockaddr *addr, socklen_t addr_len, const struct coap_transmission_parameters *params)
 Send a CoAP message from the provided service .
 
int coap_resource_send (const struct coap_resource *resource, const struct coap_packet *cpkt, const struct sockaddr *addr, socklen_t addr_len, const struct coap_transmission_parameters *params)
 Send a CoAP message from the provided resource .
 
int coap_resource_parse_observe (struct coap_resource *resource, const struct coap_packet *request, const struct sockaddr *addr)
 Parse a CoAP observe request for the provided resource .
 
int coap_resource_remove_observer_by_addr (struct coap_resource *resource, const struct sockaddr *addr)
 Lookup an observer by address and remove it from the resource .
 
int coap_resource_remove_observer_by_token (struct coap_resource *resource, const uint8_t *token, uint8_t token_len)
 Lookup an observer by token and remove it from the resource .
 

Detailed Description

CoAP Service API.

An API for applications to respond to CoAP requests