Structure for managing asynchronous state of CoAP resources.
More...
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
.
◆ 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.
◆ coap_async_state_t
◆ coap_find_async()
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
-
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. |
- Returns
- A pointer to the object identified by
id
or NULL
if not found.
Definition at line 82 of file async.c.
◆ coap_free_async()
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
-
state | The object to delete. |
Definition at line 101 of file async.c.
◆ coap_register_async()
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
-
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. |
- 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.
◆ coap_remove_async()
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
-
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. |
- 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.
◆ coap_touch_async()
Updates the time stamp of s
.
- Parameters
-
s | The state object to update. |
Definition at line 143 of file async.h.