libcoap 4.3.4-develop-214665a
Observe Subscription

Internal API for handling CoAP Observe Subscriptions (RFC7641) More...

+ Collaboration diagram for Observe Subscription:

Data Structures

struct  coap_subscription_t
 Number of notifications that may be sent non-confirmable before a confirmable message is sent to detect if observers are alive. More...
 

Functions

void coap_subscription_init (coap_subscription_t *)
 
void coap_handle_failed_notify (coap_context_t *context, coap_session_t *session, const coap_bin_const_t *token)
 Handles a failed observe notify. More...
 
coap_subscription_tcoap_add_observer (coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token, const coap_pdu_t *pdu)
 Adds the specified peer as observer for resource. More...
 
coap_subscription_tcoap_find_observer (coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token)
 Returns a subscription object for given peer. More...
 
void coap_touch_observer (coap_context_t *context, coap_session_t *session, const coap_bin_const_t *token)
 Flags that data is ready to be sent to observers. More...
 
int coap_delete_observer (coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token)
 Removes any subscription for observer from resource and releases the allocated storage. More...
 
void coap_delete_observers (coap_context_t *context, coap_session_t *session)
 Removes any subscription for session and releases the allocated storage. More...
 
void coap_persist_cleanup (coap_context_t *context)
 Close down persist tracking, releasing any memory used. More...
 

Detailed Description

Internal API for handling CoAP Observe Subscriptions (RFC7641)

Function Documentation

◆ coap_add_observer()

coap_subscription_t * coap_add_observer ( coap_resource_t resource,
coap_session_t session,
const coap_bin_const_t token,
const coap_pdu_t pdu 
)

Adds the specified peer as observer for resource.

The subscription is identified by the given token. This function returns the registered subscription information if the observer has been added, or NULL on error.

Parameters
resourceThe observed resource.
sessionThe observer's session
tokenThe token that identifies this subscription.
pduThe requesting pdu.
Returns
A pointer to the added/updated subscription information or NULL on error.

◆ coap_delete_observer()

int coap_delete_observer ( coap_resource_t resource,
coap_session_t session,
const coap_bin_const_t token 
)

Removes any subscription for observer from resource and releases the allocated storage.

The result is 1 if an observation relationship with observer and token existed, 0 otherwise.

Parameters
resourceThe observed resource.
sessionThe observer's session.
tokenThe token that identifies this subscription or NULL for any token.
Returns
1 if the observer has been deleted, 0 otherwise.
+ Here is the caller graph for this function:

◆ coap_delete_observers()

void coap_delete_observers ( coap_context_t context,
coap_session_t session 
)

Removes any subscription for session and releases the allocated storage.

Parameters
contextThe CoAP context to use.
sessionThe observer's session.
+ Here is the caller graph for this function:

◆ coap_find_observer()

coap_subscription_t * coap_find_observer ( coap_resource_t resource,
coap_session_t session,
const coap_bin_const_t token 
)

Returns a subscription object for given peer.

Parameters
resourceThe observed resource.
sessionThe observer's session
tokenThe token that identifies this subscription or NULL for any token.
Returns
A valid subscription if exists or NULL otherwise.

◆ coap_handle_failed_notify()

void coap_handle_failed_notify ( coap_context_t context,
coap_session_t session,
const coap_bin_const_t token 
)

Handles a failed observe notify.

Parameters
contextThe context holding the resource.
sessionThe session that the observe notify failed on.
tokenThe token used when the observe notify failed.
+ Here is the caller graph for this function:

◆ coap_persist_cleanup()

void coap_persist_cleanup ( coap_context_t context)

Close down persist tracking, releasing any memory used.

Parameters
contextThe current CoAP context.
+ Here is the caller graph for this function:

◆ coap_subscription_init()

void coap_subscription_init ( coap_subscription_t )

◆ coap_touch_observer()

void coap_touch_observer ( coap_context_t context,
coap_session_t session,
const coap_bin_const_t token 
)

Flags that data is ready to be sent to observers.

Parameters
contextThe CoAP context to use.
sessionThe observer's session
tokenThe corresponding token that has been used for the subscription.
+ Here is the caller graph for this function: