libcoap 4.3.3
Asynchronous Messaging

API for delayed "separate" messages. More...

+ Collaboration diagram for Asynchronous Messaging:

Functions

int coap_async_is_supported (void)
 Returns 1 if libcoap was built with separate messages enabled, 0 otherwise. More...
 
coap_async_tcoap_register_async (coap_session_t *session, const coap_pdu_t *request, coap_tick_t delay)
 Allocates a new coap_async_t object and fills its fields according to the given request. More...
 
void coap_async_set_delay (coap_async_t *async, coap_tick_t delay)
 Update the delay timeout, so changing when the registered async triggers. More...
 
void coap_async_trigger (coap_async_t *async)
 Trigger the registered async. More...
 
void coap_free_async (coap_session_t *session, coap_async_t *async)
 Releases the memory that was allocated by coap_register_async() for the object async. More...
 
coap_async_tcoap_find_async (coap_session_t *session, coap_bin_const_t token)
 Retrieves the object identified by token from the list of asynchronous transactions that are registered with context. More...
 
void coap_async_set_app_data (coap_async_t *async, void *app_data)
 Set the application data pointer held in async. More...
 
void * coap_async_get_app_data (const coap_async_t *async)
 Gets the application data pointer held in async. More...
 

Detailed Description

API for delayed "separate" messages.

A coap_context_t object holds a list of coap_async_t objects that can be used to generate a separate response in the case a result of a request cannot be delivered immediately.

Function Documentation

◆ coap_async_get_app_data()

void * coap_async_get_app_data ( const coap_async_t async)

Gets the application data pointer held in async.

Parameters
asyncThe async state object.
Returns
The applicaton data pointer.

Definition at line 231 of file coap_async.c.

◆ coap_async_is_supported()

int coap_async_is_supported ( void  )

Returns 1 if libcoap was built with separate messages enabled, 0 otherwise.

Definition at line 190 of file coap_async.c.

◆ coap_async_set_app_data()

void coap_async_set_app_data ( coap_async_t async,
void *  app_data 
)

Set the application data pointer held in async.

This overwrites any existing data pointer.

Parameters
asyncThe async state object.
app_dataThe pointer to the data.

Definition at line 225 of file coap_async.c.

◆ coap_async_set_delay()

void coap_async_set_delay ( coap_async_t async,
coap_tick_t  delay 
)

Update the delay timeout, so changing when the registered async triggers.

When the new delay expires, a copy of the original request will get sent to the appropriate request handler.

Parameters
asyncThe object to update.
delayThe amount of time to delay before sending response, 0 means wait forever.

Definition at line 205 of file coap_async.c.

◆ coap_async_trigger()

void coap_async_trigger ( coap_async_t async)

Trigger the registered async.

A copy of the original request will get sent to the appropriate request handler.

Parameters
asyncThe async object to trigger.

◆ coap_find_async()

coap_async_t * coap_find_async ( coap_session_t session,
coap_bin_const_t  token 
)

Retrieves the object identified by token from the list of asynchronous transactions that are registered with context.

This function returns a pointer to that object or NULL if not found.

Parameters
sessionThe session that is used for asynchronous transmissions.
tokenThe PDU's token of the object to retrieve.
Returns
A pointer to the object identified by token or NULL if not found.

Definition at line 217 of file coap_async.c.

◆ coap_free_async()

void coap_free_async ( coap_session_t session,
coap_async_t async 
)

Releases the memory that was allocated by coap_register_async() for the object async.

Parameters
sessionThe session to use.
asyncThe object to delete.

Definition at line 211 of file coap_async.c.

◆ coap_register_async()

coap_async_t * coap_register_async ( coap_session_t session,
const coap_pdu_t request,
coap_tick_t  delay 
)

Allocates a new coap_async_t object and fills its fields according to the given request.

This function returns a pointer to the registered coap_async_t object or NULL on error. Note that this function will return NULL in case that an object with the same identifier is already registered.

When the delay expires, a copy of the request will get sent to the appropriate request handler.

Parameters
sessionThe session that is used for asynchronous transmissions.
requestThe request that is handled asynchronously.
delayThe amount of time to delay before sending response, 0 means wait forever.
Returns
A pointer to the registered coap_async_t object or NULL in case of an error.

Definition at line 195 of file coap_async.c.