libcoap
4.3.0rc1
|
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_RELEASE_DATA 0x08 |
release application data on destruction More... | |
Typedefs | |
typedef struct coap_async_state_t | coap_async_state_t |
Functions | |
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 . More... | |
int | coap_remove_async (coap_context_t *context, coap_session_t *session, coap_mid_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_t * | coap_find_async (coap_context_t *context, coap_session_t *session, coap_mid_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... | |
Structure for managing asynchronous state of CoAP resources.
A coap_context_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.
#define COAP_ASYNC_RELEASE_DATA 0x08 |
typedef struct coap_async_state_t coap_async_state_t |
coap_async_state_t* coap_find_async | ( | coap_context_t * | context, |
coap_session_t * | session, | ||
coap_mid_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.
context | The context where the asynchronous objects are registered with. |
session | The session that is used for asynchronous transmissions. |
id | The id of the object to retrieve. |
id
or NULL
if not found. Definition at line 77 of file async.c.
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.
state | The object to delete. |
Definition at line 96 of file async.c.
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.
context | The context to use. |
session | The session that is used for asynchronous transmissions. |
request | The request that is handled asynchronously. |
flags | Flags to control state management. |
data | Opaque application data to register. Note that the storage occupied by data is released on destruction only if flag COAP_ASYNC_RELEASE_DATA is set. |
NULL
in case of an error. Definition at line 30 of file async.c.
int coap_remove_async | ( | coap_context_t * | context, |
coap_session_t * | session, | ||
coap_mid_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.
context | The context where the async object is registered. |
session | The session that is used for asynchronous transmissions. |
id | The identifier of the asynchronous transaction. |
s | Will be set to the object identified by id after removal. |
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 84 of file async.c.
COAP_STATIC_INLINE void coap_touch_async | ( | coap_async_state_t * | s | ) |