libcoap 4.3.1
Resource Observation

API for interfacing with the observe handling (RFC7641) More...

+ Collaboration diagram for Resource Observation:

Macros

#define COAP_OBSERVE_ESTABLISH   0
 The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option COAP_OPTION_OBSERVE indicates a new observe relationship for (sender address, token) is requested. More...
 
#define COAP_OBSERVE_CANCEL   1
 The value COAP_OBSERVE_CANCEL in a GET/FETCH request option COAP_OPTION_OBSERVE indicates that the observe relationship for (sender address, token) must be cancelled. More...
 

Functions

void coap_resource_set_get_observable (coap_resource_t *resource, int mode)
 Set whether a resource is observable. More...
 
int coap_resource_notify_observers (coap_resource_t *resource, const coap_string_t *query)
 Initiate the sending of an Observe packet for all observers of resource, optionally matching query if not NULL. More...
 

Detailed Description

API for interfacing with the observe handling (RFC7641)

Macro Definition Documentation

◆ COAP_OBSERVE_CANCEL

#define COAP_OBSERVE_CANCEL   1

The value COAP_OBSERVE_CANCEL in a GET/FETCH request option COAP_OPTION_OBSERVE indicates that the observe relationship for (sender address, token) must be cancelled.

Definition at line 40 of file coap_subscribe.h.

◆ COAP_OBSERVE_ESTABLISH

#define COAP_OBSERVE_ESTABLISH   0

The value COAP_OBSERVE_ESTABLISH in a GET/FETCH request option COAP_OPTION_OBSERVE indicates a new observe relationship for (sender address, token) is requested.

Definition at line 33 of file coap_subscribe.h.

Function Documentation

◆ coap_resource_notify_observers()

int coap_resource_notify_observers ( coap_resource_t resource,
const coap_string_t query 
)

Initiate the sending of an Observe packet for all observers of resource, optionally matching query if not NULL.

Parameters
resourceThe CoAP resource to use.
queryThe Query to match against or NULL
Returns
1 if the Observe has been triggered, 0 otherwise.

◆ coap_resource_set_get_observable()

void coap_resource_set_get_observable ( coap_resource_t resource,
int  mode 
)

Set whether a resource is observable.

If the resource is observable and the client has set the COAP_OPTION_OBSERVE in a request packet, then whenever the state of the resource changes (a call to coap_resource_trigger_observe()), an Observer response will get sent.

Parameters
resourceThe CoAP resource to use.
mode1 if Observable is to be set, 0 otherwise.