Loading...
Searching...
No Matches

State and Memo API. More...

Detailed Description

State and Memo API.

Author
Carl Seifert carl..nosp@m.seif.nosp@m.ert@t.nosp@m.u-dr.nosp@m.esden.nosp@m..de

Definition in file state.h.

#include <stdlib.h>
#include "ztimer.h"
#include "random.h"
#include "event.h"
#include "container.h"
#include "net/unicoap/server.h"
#include "private/packet.h"
+ Include dependency graph for state.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  unicoap_memo_t
 A type used to retain state spanning across a single or multiple message exchanges. More...
 
struct  unicoap_client_memo_t
 Client exchange. More...
 

Event Scheduling

#define UNICOAP_CLOCK   ZTIMER_MSEC
 The ztimer clock used for event scheduling.
 
typedef void(* unicoap_event_callback_t) (unicoap_scheduled_event_t *event)
 Scheduled event callback.
 
static const char * unicoap_scheduled_event_name (unicoap_scheduled_event_t *event)
 Name of scheduled event.
 
static unicoap_scheduled_event_t * unicoap_scheduled_event_of_event (event_t *event)
 Returns scheduled event subclass of event.
 
void unicoap_event_schedule (unicoap_scheduled_event_t *event, unicoap_event_callback_t callback, uint32_t duration, const char *name)
 Schedules an event on the internal unicoap queue.
 
void unicoap_event_reschedule (unicoap_scheduled_event_t *event, uint32_t duration)
 Discards the currently set timeout, and reschedules the event to be posted in duration ms.
 
void unicoap_event_cancel (unicoap_scheduled_event_t *event)
 Cancels the event.
 

Common state

#define UNICOAP_HAVE_MESSAGING_STATE    IS_USED(MODULE_UNICOAP_DRIVER_RFC7252_COMMON)
 A feature check macro that determines whether there's at least one driver that stores messaging-layer state for transmissions.
 
#define UNICOAP_HAVE_CLIENT_STATE    IS_USED(MODULE_UNICOAP_CLIENT) && CONFIG_UNICOAP_CLIENT_MEMOS_CAPACITY > 0
 A feature check macro that determines whether client state objects are supported.
 
static void * unicoap_memo_messaging_state (unicoap_memo_t *memo)
 Returns messaging state associated with memo.
 
static unicoap_memo_t * unicoap_memo_of_timeout (unicoap_scheduled_event_t *timeout)
 Returns memo of scheduled event.
 
static unicoap_memo_t * unicoap_memo_of_event (event_t *event)
 Returns memo of scheduled event.
 

Layered notification system

#define UNICOAP_LAYER_NOTIFICATION_ASYNC_FAILURE   (~(~0U >> 1))
 Event indicating a failure on the layer this message is sent from.
 
#define UNICOAP_LAYER_NOTIFICATION_STATE_RELEASE   (0)
 Event indicating a layer is finished and is releasing its allocated state objects of this exchange/transmission.
 
#define UNICOAP_LAYER_NOTIFICATION_STATE_ALLOC   (1)
 Event indicating a layer is allocating a state object.
 
typedef int unicoap_layer_notification_t
 A signal sent from one layer to another indicating a change to a state object.
 
static int unicoap_layer_notification_async_failure_to_errno (unicoap_layer_notification_t type)
 Converts notification to negative error number.
 
static unicoap_layer_notification_t unicoap_layer_notification_async_failure_from_errno (int error)
 Converts error number into notification.
 
void unicoap_messaging_notify (void *state, unicoap_layer_notification_t type, void *arg, unicoap_proto_t proto)
 Informs messaging layer of event.
 
void unicoap_exchange_notify (void *state, unicoap_layer_notification_t type, void *arg)
 Informs exchange layer of event.
 
void unicoap_exchange_notify_all (const unicoap_endpoint_t *endpoint, unicoap_layer_notification_t type, void *arg)
 Informs exchange layer of event that applies to all exchange state objects associated with given endpoint.
 

Client state

static bool unicoap_callback_is_present (const unicoap_callback_t callback)
 Determines whether the given callback is not NULL
 
static unicoap_client_memo_t * unicoap_client_memo_of_super (unicoap_memo_t *memo)
 Returns client memo of common memo state object.
 
static unicoap_client_memo_t * unicoap_client_memo_of_event (event_t *event)
 Returns client memo of event.
 
static unicoap_client_memo_t * unicoap_client_memo_of_timeout (unicoap_scheduled_event_t *timeout)
 Returns client memo of scheduled event.
 
int unicoap_client_callback_success (unicoap_client_memo_t *memo, const unicoap_packet_t *packet, unicoap_block_option_t block)
 Invokes the client callback.
 
void unicoap_client_callback_failure (unicoap_client_memo_t *memo, int error)
 Invokes the client callback indicating an error occurred.
 
unicoap_client_memo_t * unicoap_client_memo_create (const unicoap_endpoint_t *endpoint)
 Allocates and sets up a new memo.
 
unicoap_client_memo_t * unicoap_client_memo_find_token (const unicoap_endpoint_t *endpoint, const uint8_t *token, size_t token_length)
 Tries to find a client exchange memo by endpoint and token.
 
unicoap_client_memo_t * unicoap_client_memo_find_refno (int refno)
 Tries to find client state object based on reference number.
 
int unicoap_client_memo_assign_refno (unicoap_client_memo_t *memo)
 Assigns a refno to the given client memo.
 
void unicoap_client_memo_free (unicoap_client_memo_t *memo, int error)
 Frees memo and associated buffers.