libcoap  4.3.0
Observe Subscription (Internal)

CoAP Observe Subscription Structures, Enums and Functions that are not exposed to applications. More...

Data Structures

struct  coap_subscription_t
 Subscriber information. More...
 

Macros

#define COAP_OBS_MAX_NON   5
 Number of notifications that may be sent non-confirmable before a confirmable message is sent to detect if observers are alive. More...
 
#define COAP_OBS_MAX_FAIL   3
 Number of confirmable notifications that may fail (i.e. More...
 

Functions

void coap_subscription_init (coap_subscription_t *)
 
void coap_handle_failed_notify (coap_context_t *context, coap_session_t *session, const coap_binary_t *token)
 Handles a failed observe notify. More...
 
void coap_check_notify (coap_context_t *context)
 Checks all known resources to see if they are dirty and then notifies subscribed observers. More...
 
coap_subscription_tcoap_add_observer (coap_resource_t *resource, coap_session_t *session, const coap_binary_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_binary_t *token)
 Returns a subscription object for given peer. More...
 
void coap_touch_observer (coap_context_t *context, coap_session_t *session, const coap_binary_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_binary_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...
 

Detailed Description

CoAP Observe Subscription Structures, Enums and Functions that are not exposed to applications.

Macro Definition Documentation

◆ COAP_OBS_MAX_FAIL

#define COAP_OBS_MAX_FAIL   3

Number of confirmable notifications that may fail (i.e.

time out without being ACKed) before an observer is removed. The maximum value for COAP_OBS_MAX_FAIL is 3.

Definition at line 43 of file coap_subscribe_internal.h.

◆ COAP_OBS_MAX_NON

#define COAP_OBS_MAX_NON   5

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

The maximum allowed value here is 15.

Definition at line 34 of file coap_subscribe_internal.h.

Function Documentation

◆ coap_add_observer()

coap_subscription_t* coap_add_observer ( coap_resource_t resource,
coap_session_t session,
const coap_binary_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.

Definition at line 721 of file resource.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_check_notify()

void coap_check_notify ( coap_context_t context)

Checks all known resources to see if they are dirty and then notifies subscribed observers.

Parameters
contextThe context to check for dirty resources.

Definition at line 1062 of file resource.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_delete_observer()

int coap_delete_observer ( coap_resource_t resource,
coap_session_t session,
const coap_binary_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.

Definition at line 816 of file resource.c.

+ Here is the call graph for this function:
+ 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.

Definition at line 842 of file resource.c.

+ Here is the call graph for this function:
+ 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_binary_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.

Definition at line 686 of file resource.c.

+ Here is the caller graph for this function:

◆ coap_handle_failed_notify()

void coap_handle_failed_notify ( coap_context_t context,
coap_session_t session,
const coap_binary_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.

Definition at line 1125 of file resource.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ coap_subscription_init()

void coap_subscription_init ( coap_subscription_t s)

Definition at line 15 of file subscribe.c.

+ Here is the caller graph for this function:

◆ coap_touch_observer()

void coap_touch_observer ( coap_context_t context,
coap_session_t session,
const coap_binary_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.

Definition at line 803 of file resource.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: