Loading...
Searching...
No Matches
Observe Subscription
Libcoap Internal API

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.
void | coap_check_notify (coap_context_t *context)
| Checks all known resources to see if they are dirty and then notifies subscribed observers.
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`.
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`.
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.
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.
void | coap_delete_observers (coap_context_t *context, coap_session_t *session)
| Removes any subscription for `session` and releases the allocated storage.
void | coap_persist_cleanup (coap_context_t *context)
| Close down persist tracking, releasing any memory used.

## 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

  resource | The observed resource.
  session | The observer's session
  token | The token that identifies this subscription.
  pdu | The requesting pdu.

Returns
  A pointer to the added/updated subscription information or `NULL` on error.

## 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

  context | The context to check for dirty resources.

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_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

  resource | The observed resource.
  session | The observer's session.
  token | The 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

  context | The CoAP context to use.
  session | The 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

  resource | The observed resource.
  session | The observer's session
  token | The 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

  context | The context holding the resource.
  session | The session that the observe notify failed on.
  token | The 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

  context | The 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

  context | The CoAP context to use.
  session | The observer's session
  token | The corresponding token that has been used for the subscription.

Here is the caller graph for this function: