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
.
#define COAP_ASYNC_CONFIRM 0x01 |
send confirmable response
Definition at line 59 of file async.h.
#define COAP_ASYNC_OBSERVED 0x04 |
the resource is being observed
Definition at line 61 of file async.h.
#define COAP_ASYNC_RELEASE_DATA 0x08 |
release application data on destruction
Definition at line 64 of file async.h.
#define COAP_ASYNC_SEPARATE 0x02 |
send separate response
Definition at line 60 of file async.h.
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. |
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 74 of file async.c.
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
-
Definition at line 93 of file async.c.
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. |
peer | The remote peer that is to be asynchronously notified. |
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 25 of file async.c.
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. |
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 81 of file async.c.
Updates the time stamp of s
.
- Parameters
-
s | The state object to update. |
Definition at line 141 of file async.h.