libcoap  4.2.0
Asynchronous Messaging

Structure for managing asynchronous state of CoAP resources. More...

Data Structures

struct  coap_async_state_t
 

Macros

#define COAP_ASYNC_CONFIRM   0x01
 send confirmable response More...
 
#define COAP_ASYNC_SEPARATE   0x02
 send separate response More...
 
#define COAP_ASYNC_OBSERVED   0x04
 the resource is being observed More...
 
#define COAP_ASYNC_RELEASE_DATA   0x08
 release application data on destruction More...
 

Typedefs

typedef struct coap_async_state_t coap_async_state_t
 

Functions

coap_async_state_tcoap_register_async (coap_context_t *context, coap_session_t *session, coap_pdu_t *request, unsigned char flags, void *data)
 Allocates a new coap_async_state_t object and fills its fields according to the given request. More...
 
int coap_remove_async (coap_context_t *context, coap_session_t *session, coap_tid_t id, coap_async_state_t **s)
 Removes the state object identified by id from context. More...
 
void coap_free_async (coap_async_state_t *state)
 Releases the memory that was allocated by coap_async_state_init() for the object s. More...
 
coap_async_state_tcoap_find_async (coap_context_t *context, coap_session_t *session, coap_tid_t id)
 Retrieves the object identified by id from the list of asynchronous transactions that are registered with context. More...
 
COAP_STATIC_INLINE void coap_touch_async (coap_async_state_t *s)
 Updates the time stamp of s. More...
 

Detailed Description

Structure for managing asynchronous state of CoAP resources.

A coap_resource_t object holds a list of coap_async_state_t objects that can be used to generate a separate response in case a result of an operation cannot be delivered in time, or the resource has been explicitly subscribed to with the option observe.

Macro Definition Documentation

◆ COAP_ASYNC_CONFIRM

#define COAP_ASYNC_CONFIRM   0x01

send confirmable response

Definition at line 57 of file async.h.

◆ COAP_ASYNC_OBSERVED

#define COAP_ASYNC_OBSERVED   0x04

the resource is being observed

Definition at line 59 of file async.h.

◆ COAP_ASYNC_RELEASE_DATA

#define COAP_ASYNC_RELEASE_DATA   0x08

release application data on destruction

Definition at line 62 of file async.h.

◆ COAP_ASYNC_SEPARATE

#define COAP_ASYNC_SEPARATE   0x02

send separate response

Definition at line 58 of file async.h.

Typedef Documentation

◆ coap_async_state_t

Function Documentation

◆ coap_find_async()

coap_async_state_t* coap_find_async ( coap_context_t context,
coap_session_t session,
coap_tid_t  id 
)

Retrieves the object identified by id 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
contextThe context where the asynchronous objects are registered with.
sessionThe session that is used for asynchronous transmissions.
idThe id of the object to retrieve.
Returns
A pointer to the object identified by id or NULL if not found.

Definition at line 82 of file async.c.

+ Here is the caller graph for this function:

◆ coap_free_async()

void coap_free_async ( coap_async_state_t state)

Releases the memory that was allocated by coap_async_state_init() for the object s.

The registered application data will be released automatically if COAP_ASYNC_RELEASE_DATA is set.

Parameters
stateThe object to delete.

Definition at line 101 of file async.c.

+ Here is the call graph for this function:

◆ coap_register_async()

coap_async_state_t* coap_register_async ( coap_context_t context,
coap_session_t session,
coap_pdu_t request,
unsigned char  flags,
void *  data 
)

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

The flags are used to control generation of empty ACK responses to stop retransmissions and to release registered data when the resource is deleted by coap_free_async(). 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.

Parameters
contextThe context to use.
sessionThe session that is used for asynchronous transmissions.
requestThe request that is handled asynchronously.
flagsFlags to control state management.
dataOpaque application data to register. Note that the storage occupied by data is released on destruction only if flag COAP_ASYNC_RELEASE_DATA is set.
Returns
A pointer to the registered coap_async_state_t object or NULL in case of an error.

Definition at line 35 of file async.c.

+ Here is the call graph for this function:

◆ coap_remove_async()

int coap_remove_async ( coap_context_t context,
coap_session_t session,
coap_tid_t  id,
coap_async_state_t **  s 
)

Removes the state object identified by id from context.

The removed object is returned in s, if found. Otherwise, s is undefined. This function returns 1 if the object was removed, 0 otherwise. Note that the storage allocated for the stored object is not released by this functions. You will have to call coap_free_async() to do so.

Parameters
contextThe context where the async object is registered.
sessionThe session that is used for asynchronous transmissions.
idThe identifier of the asynchronous transaction.
sWill be set to the object identified by id after removal.
Returns
1 if object was removed and s updated, or 0 if no object was found with the given id. s is valid only if the return value is 1.

Definition at line 89 of file async.c.

+ Here is the call graph for this function:

◆ coap_touch_async()

COAP_STATIC_INLINE void coap_touch_async ( coap_async_state_t s)

Updates the time stamp of s.

Parameters
sThe state object to update.

Definition at line 143 of file async.h.

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