Zephyr Project API  3.3.0
A Scalable Open Source RTOS
zbus.h File Reference
#include <string.h>
#include <zephyr/kernel.h>

Go to the source code of this file.

Data Structures

struct  zbus_channel
 Type used to represent a channel. More...
 
struct  zbus_observer
 Type used to represent an observer. More...
 

Macros

#define ZBUS_OBS_DECLARE(...)   FOR_EACH(_ZBUS_OBS_EXTERN, (;), __VA_ARGS__)
 
#define ZBUS_CHAN_DECLARE(...)   FOR_EACH(_ZBUS_CHAN_EXTERN, (;), __VA_ARGS__)
 
#define ZBUS_OBSERVERS_EMPTY
 
#define ZBUS_OBSERVERS(...)   __VA_ARGS__
 
#define ZBUS_CHAN_DEFINE(_name, _type, _validator, _user_data, _observers, _init_val)
 Zbus channel definition. More...
 
#define ZBUS_MSG_INIT(_val, ...)
 Initialize a message. More...
 
#define ZBUS_SUBSCRIBER_DEFINE(_name, _queue_size)
 Define and initialize a subscriber. More...
 
#define ZBUS_LISTENER_DEFINE(_name, _cb)
 Define and initialize a listener. More...
 

Functions

int zbus_chan_pub (const struct zbus_channel *chan, const void *msg, k_timeout_t timeout)
 Publish to a channel. More...
 
int zbus_chan_read (const struct zbus_channel *chan, void *msg, k_timeout_t timeout)
 Read a channel. More...
 
int zbus_chan_claim (const struct zbus_channel *chan, k_timeout_t timeout)
 Claim a channel. More...
 
int zbus_chan_finish (const struct zbus_channel *chan)
 Finish a channel claim. More...
 
int zbus_chan_notify (const struct zbus_channel *chan, k_timeout_t timeout)
 Force a channel notification. More...
 
static const char * zbus_chan_name (const struct zbus_channel *chan)
 Get the channel's name. More...
 
static void * zbus_chan_msg (const struct zbus_channel *chan)
 Get the reference for a channel message directly. More...
 
static const void * zbus_chan_const_msg (const struct zbus_channel *chan)
 Get a constant reference for a channel message directly. More...
 
static uint16_t zbus_chan_msg_size (const struct zbus_channel *chan)
 Get the channel's message size. More...
 
static void * zbus_chan_user_data (const struct zbus_channel *chan)
 Get the channel's user data. More...
 
int zbus_chan_add_obs (const struct zbus_channel *chan, const struct zbus_observer *obs, k_timeout_t timeout)
 Add an observer to a channel. More...
 
int zbus_chan_rm_obs (const struct zbus_channel *chan, const struct zbus_observer *obs, k_timeout_t timeout)
 Remove an observer from a channel. More...
 
struct k_mem_slab * zbus_runtime_obs_pool (void)
 Get zbus runtime observers pool. More...
 
static int zbus_obs_set_enable (struct zbus_observer *obs, bool enabled)
 Change the observer state. More...
 
static const char * zbus_obs_name (const struct zbus_observer *obs)
 Get the observer's name. More...
 
int zbus_sub_wait (const struct zbus_observer *sub, const struct zbus_channel **chan, k_timeout_t timeout)
 Wait for a channel notification. More...
 
bool zbus_iterate_over_channels (bool(*iterator_func)(const struct zbus_channel *chan))
 Iterate over channels. More...
 
bool zbus_iterate_over_observers (bool(*iterator_func)(const struct zbus_observer *obs))
 Iterate over observers. More...