6#ifndef ZEPHYR_INCLUDE_ZBUS_ZBUS_H_
7#define ZEPHYR_INCLUDE_ZBUS_ZBUS_H_
49#if defined(CONFIG_ZBUS_PRIORITY_BOOST)
53 int highest_observer_priority;
56#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS) || defined(__DOXYGEN__)
63#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_ISOLATION) || defined(__DOXYGEN__)
70#if defined(CONFIG_ZBUS_CHANNEL_PUBLISH_STATS) || defined(__DOXYGEN__)
96#if defined(CONFIG_ZBUS_CHANNEL_NAME) || defined(__DOXYGEN__)
100#if defined(CONFIG_ZBUS_CHANNEL_ID) || defined(__DOXYGEN__)
153#if defined(CONFIG_ZBUS_PRIORITY_BOOST)
175#if defined(CONFIG_ZBUS_OBSERVER_NAME) || defined(__DOXYGEN__)
192#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER) || defined(__DOXYGEN__)
199#if defined(CONFIG_ZBUS_ASYNC_LISTENER) || defined(__DOXYGEN__)
209struct zbus_channel_observation_mask {
216struct zbus_channel_observation {
217 const struct zbus_channel *chan;
218 const struct zbus_observer *obs;
222#define _ZBUS_CPP_EXTERN extern
224#define _ZBUS_CPP_EXTERN
227#define ZBUS_MIN_THREAD_PRIORITY (CONFIG_NUM_PREEMPT_PRIORITIES - 1)
229#if defined(CONFIG_ZBUS_ASSERT_MOCK)
230#define _ZBUS_ASSERT(_cond, _fmt, ...) \
233 printk("ZBUS ASSERT: "); \
234 printk(_fmt, ##__VA_ARGS__); \
240#define _ZBUS_ASSERT(_cond, _fmt, ...) __ASSERT(_cond, _fmt, ##__VA_ARGS__)
243#if defined(CONFIG_ZBUS_CHANNEL_NAME)
244#define ZBUS_CHANNEL_NAME_INIT(_name) .name = #_name,
245#define _ZBUS_CHAN_NAME(_chan) (_chan)->name
247#define ZBUS_CHANNEL_NAME_INIT(_name)
248#define _ZBUS_CHAN_NAME(_chan) ""
251#if defined(CONFIG_ZBUS_OBSERVER_NAME)
252#define ZBUS_OBSERVER_NAME_INIT(_name) .name = #_name,
253#define _ZBUS_OBS_NAME(_obs) (_obs)->name
255#define ZBUS_OBSERVER_NAME_INIT(_name)
256#define _ZBUS_OBS_NAME(_obs) ""
259#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS)
260#define ZBUS_RUNTIME_OBSERVERS_LIST_DECL(_slist_name) static sys_slist_t _slist_name
261#define ZBUS_RUNTIME_OBSERVERS_LIST_INIT(_slist_name) .runtime_observers = &_slist_name,
263#define ZBUS_RUNTIME_OBSERVERS_LIST_DECL(_slist_name)
264#define ZBUS_RUNTIME_OBSERVERS_LIST_INIT(_slist_name)
267#define _ZBUS_OBS_EXTERN(_name) extern const struct zbus_observer _name
269#define _ZBUS_CHAN_EXTERN(_name) extern const struct zbus_channel _name
271#define ZBUS_REF(_value) &(_value)
273#define FOR_EACH_FIXED_ARG_NONEMPTY_TERM(F, sep, fixed_arg, ...) \
275 NUM_VA_ARGS_LESS_1( \
276 LIST_DROP_EMPTY(__VA_ARGS__, _)), \
278 (FOR_EACH_IDX_FIXED_ARG( \
280 LIST_DROP_EMPTY(__VA_ARGS__)) \
283#define _ZBUS_OBSERVATION_PREFIX(_idx) \
284 GET_ARG_N(_idx, 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, \
285 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, \
286 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, \
287 58, 59, 60, 61, 62, 63)
289#define _ZBUS_CHAN_OBSERVATION(_idx, _obs, _chan) \
290 const STRUCT_SECTION_ITERABLE( \
291 zbus_channel_observation, \
292 _CONCAT(_chan, _ZBUS_OBSERVATION_PREFIX(UTIL_INC(_idx)))) = {.chan = &_chan, \
294 STRUCT_SECTION_ITERABLE(zbus_channel_observation_mask, \
295 _CONCAT(_CONCAT(_chan, _ZBUS_OBSERVATION_PREFIX(UTIL_INC(_idx))), \
296 _mask)) = {.enabled = false};
298#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS) || defined(__DOXYGEN__)
299#define _ZBUS_RUNTIME_OBSERVERS(_name) .observers = &(_CONCAT(_observers_, _name)),
300#define _ZBUS_RUNTIME_OBSERVERS_DECL(_name) static sys_slist_t _CONCAT(_observers_, _name);
302#define _ZBUS_RUNTIME_OBSERVERS(_name)
303#define _ZBUS_RUNTIME_OBSERVERS_DECL(_name)
306#define _ZBUS_MESSAGE_NAME(_name) _CONCAT(_zbus_message_, _name)
309#define _ZBUS_CHAN_DEFINE(_name, _id, _type, _validator, _user_data) \
310 static struct zbus_channel_data _CONCAT(_zbus_chan_data_, _name) = { \
311 .observers_start_idx = -1, \
312 .observers_end_idx = -1, \
313 .sem = Z_SEM_INITIALIZER(_CONCAT(_zbus_chan_data_, _name).sem, 1, 1), \
314 IF_ENABLED(CONFIG_ZBUS_PRIORITY_BOOST, \
315 (.highest_observer_priority = ZBUS_MIN_THREAD_PRIORITY,)) \
316 IF_ENABLED(CONFIG_ZBUS_RUNTIME_OBSERVERS, \
317 (.observers = SYS_SLIST_STATIC_INIT( \
318 &_CONCAT(_zbus_chan_data_, _name).observers),)) \
319 IF_ENABLED(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_ISOLATION, \
320 (.msg_subscriber_pool = NULL,)) \
322 _ZBUS_CPP_EXTERN const STRUCT_SECTION_ITERABLE(zbus_channel, _name) = { \
323 ZBUS_CHANNEL_NAME_INIT(_name) \
324 IF_ENABLED(CONFIG_ZBUS_CHANNEL_ID, (.id = _id,)) \
325 .message = &_ZBUS_MESSAGE_NAME(_name), \
326 .message_size = sizeof(_type), \
327 .user_data = _user_data, \
328 .validator = _validator, \
329 .data = &_CONCAT(_zbus_chan_data_, _name), \
348#define ZBUS_CHAN_ADD_OBS_WITH_MASK(_chan, _obs, _masked, _prio) \
349 const STRUCT_SECTION_ITERABLE(zbus_channel_observation, \
350 _CONCAT(_CONCAT(_chan, zz), _CONCAT(_prio, _obs))) = { \
354 STRUCT_SECTION_ITERABLE(zbus_channel_observation_mask, \
355 _CONCAT(_CONCAT(_CONCAT(_chan, zz), _CONCAT(_prio, _obs)), \
356 _mask)) = {.enabled = _masked}
369#define ZBUS_CHAN_ADD_OBS(_chan, _obs, _prio) ZBUS_CHAN_ADD_OBS_WITH_MASK(_chan, _obs, false, _prio)
376#define ZBUS_OBS_DECLARE(...) FOR_EACH_NONEMPTY_TERM(_ZBUS_OBS_EXTERN, (;), __VA_ARGS__)
383#define ZBUS_CHAN_DECLARE(...) FOR_EACH(_ZBUS_CHAN_EXTERN, (;), __VA_ARGS__)
389#define ZBUS_OBSERVERS_EMPTY
396#define ZBUS_OBSERVERS(...) __VA_ARGS__
402#define ZBUS_CHAN_ID_INVALID UINT32_MAX
419#define ZBUS_CHAN_DEFINE(_name, _type, _validator, _user_data, _observers, _init_val) \
420 static _type _ZBUS_MESSAGE_NAME(_name) = _init_val; \
421 _ZBUS_CHAN_DEFINE(_name, ZBUS_CHAN_ID_INVALID, _type, _validator, _user_data); \
423 ZBUS_OBS_DECLARE(_observers); \
425 FOR_EACH_FIXED_ARG_NONEMPTY_TERM(_ZBUS_CHAN_OBSERVATION, (;), _name, _observers)
443#define ZBUS_CHAN_DEFINE_WITH_ID(_name, _id, _type, _validator, _user_data, _observers, _init_val) \
444 static _type _ZBUS_MESSAGE_NAME(_name) = _init_val; \
445 _ZBUS_CHAN_DEFINE(_name, _id, _type, _validator, _user_data); \
447 ZBUS_OBS_DECLARE(_observers); \
449 FOR_EACH_FIXED_ARG_NONEMPTY_TERM(_ZBUS_CHAN_OBSERVATION, (;), _name, _observers)
460#define ZBUS_MSG_INIT(_val, ...) {_val, ##__VA_ARGS__}
475#define ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, _enable) \
476 K_MSGQ_DEFINE(_zbus_observer_queue_##_name, \
477 sizeof(struct zbus_channel *), \
478 _queue_size, sizeof(struct zbus_channel *) \
480 static struct zbus_observer_data _CONCAT(_zbus_obs_data_, _name) = { \
481 .enabled = _enable, \
482 IF_ENABLED(CONFIG_ZBUS_PRIORITY_BOOST, ( \
483 .priority = ZBUS_MIN_THREAD_PRIORITY, \
486 _ZBUS_CPP_EXTERN const STRUCT_SECTION_ITERABLE(zbus_observer, _name) = { \
487 ZBUS_OBSERVER_NAME_INIT(_name) \
488 .type = ZBUS_OBSERVER_SUBSCRIBER_TYPE, \
489 .data = &_CONCAT(_zbus_obs_data_, _name), \
490 .queue = &_zbus_observer_queue_##_name, \
505#define ZBUS_SUBSCRIBER_DEFINE(_name, _queue_size) \
506 ZBUS_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _queue_size, true)
521#define ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, _enable) \
522 static struct zbus_observer_data _CONCAT(_zbus_obs_data_, _name) = { \
523 .enabled = _enable, \
524 IF_ENABLED(CONFIG_ZBUS_PRIORITY_BOOST, ( \
525 .priority = ZBUS_MIN_THREAD_PRIORITY, \
528 _ZBUS_CPP_EXTERN const STRUCT_SECTION_ITERABLE(zbus_observer, _name) = { \
529 ZBUS_OBSERVER_NAME_INIT(_name) \
530 .type = ZBUS_OBSERVER_LISTENER_TYPE, \
531 .data = &_CONCAT(_zbus_obs_data_, _name), \
546#define ZBUS_LISTENER_DEFINE(_name, _cb) ZBUS_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, true)
560#define ZBUS_MSG_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, _enable) \
561 static K_FIFO_DEFINE(_zbus_observer_fifo_##_name); \
562 static struct zbus_observer_data _CONCAT(_zbus_obs_data_, _name) = { \
563 .enabled = _enable, \
564 IF_ENABLED(CONFIG_ZBUS_PRIORITY_BOOST, ( \
565 .priority = ZBUS_MIN_THREAD_PRIORITY, \
568 _ZBUS_CPP_EXTERN const STRUCT_SECTION_ITERABLE(zbus_observer, _name) = { \
569 ZBUS_OBSERVER_NAME_INIT(_name) \
570 .type = ZBUS_OBSERVER_MSG_SUBSCRIBER_TYPE, \
571 .data = &_CONCAT(_zbus_obs_data_, _name), \
572 .message_fifo = &_zbus_observer_fifo_##_name, \
587#define ZBUS_MSG_SUBSCRIBER_DEFINE(_name) ZBUS_MSG_SUBSCRIBER_DEFINE_WITH_ENABLE(_name, true)
589#if defined(CONFIG_ZBUS_ASYNC_LISTENER) || defined(__DOXYGEN__)
591struct zbus_async_listener_work {
593 struct k_fifo *message_fifo;
595 void (*callback)(
const struct zbus_channel *chan,
const void *msg);
598void async_listener_work_handler(
struct k_work *item);
615#define ZBUS_ASYNC_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, _enable) \
616 static K_FIFO_DEFINE(_zbus_observer_work_fifo_##_name); \
617 static struct zbus_async_listener_work _zbus_observer_work_##_name = { \
618 .work = Z_WORK_INITIALIZER(async_listener_work_handler), \
619 .message_fifo = &_CONCAT(_zbus_observer_work_fifo_, _name), \
620 .queue = &k_sys_work_q, \
623 static struct zbus_observer_data _CONCAT(_zbus_obs_data_, _name) = { \
624 .enabled = _enable, \
625 IF_ENABLED(CONFIG_ZBUS_PRIORITY_BOOST, ( \
626 .priority = ZBUS_MIN_THREAD_PRIORITY, \
629 _ZBUS_CPP_EXTERN const STRUCT_SECTION_ITERABLE(zbus_observer, _name) = { \
630 ZBUS_OBSERVER_NAME_INIT(_name) \
631 .type = ZBUS_OBSERVER_ASYNC_LISTENER_TYPE, \
632 .data = &_CONCAT(_zbus_obs_data_, _name), \
633 .work = &_CONCAT(_zbus_observer_work_, _name).work, \
648#define ZBUS_ASYNC_LISTENER_DEFINE(_name, _cb) \
649 ZBUS_ASYNC_LISTENER_DEFINE_WITH_ENABLE(_name, _cb, true)
683 static struct k_spinlock zbus_async_listener_slock;
686 struct zbus_async_listener_work *async_listener =
689 async_listener->queue = queue;
797#if defined(CONFIG_ZBUS_CHANNEL_NAME) || defined(__DOXYGEN__)
810 __ASSERT(chan !=
NULL,
"chan is required");
817#if defined(CONFIG_ZBUS_CHANNEL_ID) || defined(__DOXYGEN__)
831#if defined(CONFIG_ZBUS_CHANNEL_NAME) || defined(__DOXYGEN__)
845#if defined(CONFIG_ZBUS_RUNTIME_CHANNEL_REGISTRATION) || defined(__DOXYGEN__)
865 __ASSERT(chan !=
NULL,
"chan is required");
866 __ASSERT(
data !=
NULL,
"data is required");
868 __ASSERT(
message_size > 0,
"message_size must be positive");
869#if defined(CONFIG_ZBUS_CHANNEL_NAME)
870 __ASSERT(
name !=
NULL,
"name is required");
873#if defined(CONFIG_ZBUS_CHANNEL_ID)
883#if defined(CONFIG_ZBUS_PRIORITY_BOOST)
884 data->highest_observer_priority = ZBUS_MIN_THREAD_PRIORITY;
917#if defined(CONFIG_ZTEST)
922void zbus_runtime_channel_unregister_all(
void);
942 __ASSERT(chan !=
NULL,
"chan is required");
963 __ASSERT(chan !=
NULL,
"chan is required");
979 __ASSERT(chan !=
NULL,
"chan is required");
995 __ASSERT(chan !=
NULL,
"chan is required");
1000#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER_NET_BUF_POOL_ISOLATION) || defined(__DOXYGEN__)
1011 __ASSERT(chan !=
NULL,
"chan is required");
1012 __ASSERT(pool !=
NULL,
"pool is required");
1019#if defined(CONFIG_ZBUS_CHANNEL_PUBLISH_STATS) || defined(__DOXYGEN__)
1034 __ASSERT(chan !=
NULL,
"chan is required");
1051 __ASSERT(chan !=
NULL,
"chan is required");
1067 __ASSERT(chan !=
NULL,
"chan is required");
1083 __ASSERT(chan !=
NULL,
"chan is required");
1118#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS) || defined(__DOXYGEN__)
1127#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_ALLOC_NONE)
1132#if defined(CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_ALLOC_NONE) || defined(__DOXYGEN__)
1162 ARG_UNUSED(timeout);
1168#if !defined(CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_ALLOC_NONE) || defined(__DOXYGEN__)
1197 ARG_UNUSED(timeout);
1250 _ZBUS_ASSERT(obs !=
NULL,
"obs is required");
1251 _ZBUS_ASSERT(enable !=
NULL,
"enable is required");
1290#if defined(CONFIG_ZBUS_OBSERVER_NAME) || defined(__DOXYGEN__)
1303 __ASSERT(obs !=
NULL,
"obs is required");
1310#if defined(CONFIG_ZBUS_PRIORITY_BOOST) || defined(__DOXYGEN__)
1357#if defined(CONFIG_ZBUS_MSG_SUBSCRIBER) || defined(__DOXYGEN__)
Header file for configurable error checking.
int64_t k_uptime_ticks(void)
Get system uptime, in system ticks.
uint32_t k_ticks_t
Tick precision used in timeout APIs.
Definition clock.h:48
static int64_t k_uptime_get(void)
Get system uptime.
Definition kernel.h:2265
int k_sem_init(struct k_sem *sem, unsigned int initial_count, unsigned int limit)
Initialize a semaphore.
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:52
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:42
#define K_SPINLOCK(lck)
Guards a code block with the given spinlock, automatically acquiring the lock before executing the co...
Definition spinlock.h:457
#define CONTAINER_OF(ptr, type, field)
Get a pointer to a structure containing the element.
Definition util.h:281
#define CHECKIF(expr)
Guard error-handling code with a configurable check.
Definition check.h:52
#define EINVAL
Invalid argument.
Definition errno.h:61
#define ENOTSUP
Unsupported value.
Definition errno.h:115
#define k_ticks_to_ms_floor64(t)
Convert ticks to milliseconds.
Definition time_units.h:1734
int zbus_chan_claim(const struct zbus_channel *chan, k_timeout_t timeout)
Claim a channel.
static const char * zbus_chan_name(const struct zbus_channel *chan)
Get the channel's name.
Definition zbus.h:808
static uint32_t zbus_chan_pub_stats_avg_period(const struct zbus_channel *chan)
Get the average period between publishes to a channel.
Definition zbus.h:1081
bool zbus_iterate_over_observers_with_user_data(bool(*iterator_func)(const struct zbus_observer *obs, void *user_data), void *user_data)
Iterate over observers with user data.
bool zbus_iterate_over_observers(bool(*iterator_func)(const struct zbus_observer *obs))
Iterate over observers.
static int zbus_obs_is_enabled(const struct zbus_observer *obs, bool *enable)
Get the observer state.
Definition zbus.h:1248
static void zbus_chan_set_msg_sub_pool(const struct zbus_channel *chan, struct net_buf_pool *pool)
Set the channel's msg subscriber net_buf pool.
Definition zbus.h:1008
int zbus_obs_is_chan_notification_masked(const struct zbus_observer *obs, const struct zbus_channel *chan, bool *masked)
Get the notifications masking state from a channel to an observer.
bool(* zbus_validator)(const void *msg, size_t msg_size)
Check validity of message before publishing.
Definition zbus.h:87
int zbus_obs_detach_from_thread(const struct zbus_observer *obs)
Clear the observer thread priority by detaching it from a thread.
const struct zbus_channel * zbus_chan_from_name(const char *name)
Retrieve a zbus channel from its name string.
static uint64_t zbus_chan_pub_stats_msg_age(const struct zbus_channel *chan)
Get the age of a message in a channel.
Definition zbus.h:1101
static int zbus_async_listener_set_work_queue(const struct zbus_observer *obs, struct k_work_q *queue)
Set the work queue for an async listener.
Definition zbus.h:668
static uint32_t zbus_chan_pub_stats_count(const struct zbus_channel *chan)
Get the number of times a channel has been published to.
Definition zbus.h:1065
static const char * zbus_obs_name(const struct zbus_observer *obs)
Get the observer's name.
Definition zbus.h:1301
bool zbus_iterate_over_channels(bool(*iterator_func)(const struct zbus_channel *chan))
Iterate over channels.
int zbus_chan_notify(const struct zbus_channel *chan, k_timeout_t timeout)
Force a channel notification.
int zbus_chan_add_obs_with_node(const struct zbus_channel *chan, const struct zbus_observer *obs, struct zbus_observer_node *node, k_timeout_t timeout)
Add an observer to a channel.
int zbus_chan_finish(const struct zbus_channel *chan)
Finish a channel claim.
int zbus_runtime_channel_register(struct zbus_runtime_channel *chan)
Register a runtime channel with the ZBus infrastructure.
int zbus_chan_read(const struct zbus_channel *chan, void *msg, k_timeout_t timeout)
Read a channel.
int zbus_sub_wait(const struct zbus_observer *sub, const struct zbus_channel **chan, k_timeout_t timeout)
Wait for a channel notification.
zbus_observer_type
Type used to represent an observer type.
Definition zbus.h:142
static uint16_t zbus_chan_msg_size(const struct zbus_channel *chan)
Get the channel's message size.
Definition zbus.h:977
int zbus_obs_set_chan_notification_mask(const struct zbus_observer *obs, const struct zbus_channel *chan, bool masked)
Mask notifications from a channel to an observer.
int zbus_obs_set_enable(const struct zbus_observer *obs, bool enabled)
Change the observer state.
static void * zbus_chan_msg(const struct zbus_channel *chan)
Get the reference for a channel message directly.
Definition zbus.h:940
bool zbus_iterate_over_channels_with_user_data(bool(*iterator_func)(const struct zbus_channel *chan, void *user_data), void *user_data)
Iterate over channels with user data.
int zbus_obs_attach_to_thread(const struct zbus_observer *obs)
Set the observer thread priority by attaching it to a thread.
static void * zbus_chan_user_data(const struct zbus_channel *chan)
Get the channel's user data.
Definition zbus.h:993
static k_ticks_t zbus_chan_pub_stats_last_time(const struct zbus_channel *chan)
Get the time a channel was last published to.
Definition zbus.h:1049
const struct zbus_channel * zbus_chan_from_id(uint32_t channel_id)
Retrieve a zbus channel from its numeric identifier.
int zbus_runtime_channel_unregister(struct zbus_runtime_channel *chan)
Unregister a runtime channel from the ZBus infrastructure.
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.
int zbus_chan_pub(const struct zbus_channel *chan, const void *msg, k_timeout_t timeout)
Publish to a channel.
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.
static void zbus_chan_pub_stats_update(const struct zbus_channel *chan)
Update the publishing statistics for a channel.
Definition zbus.h:1032
int zbus_sub_wait_msg(const struct zbus_observer *sub, const struct zbus_channel **chan, void *msg, k_timeout_t timeout)
Wait for a channel message.
static void zbus_runtime_channel_init(struct zbus_runtime_channel *chan, struct zbus_channel_data *data, const char *name, uint32_t id, zbus_validator validator, void *message, size_t message_size, void *user_data)
Initialise a ZBus runtime channel structure.
Definition zbus.h:860
static const void * zbus_chan_const_msg(const struct zbus_channel *chan)
Get a constant reference for a channel message directly.
Definition zbus.h:961
@ ZBUS_OBSERVER_LISTENER_TYPE
Definition zbus.h:143
@ ZBUS_OBSERVER_ASYNC_LISTENER_TYPE
Definition zbus.h:146
@ ZBUS_OBSERVER_SUBSCRIBER_TYPE
Definition zbus.h:144
@ ZBUS_OBSERVER_MSG_SUBSCRIBER_TYPE
Definition zbus.h:145
#define NULL
Definition iar_missing_defs.h:20
#define bool
Definition stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
#define UINT64_MAX
Definition stdint.h:30
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT16_TYPE__ int16_t
Definition stdint.h:73
void * memset(void *buf, int c, size_t n)
Kernel FIFO structure.
Definition kernel.h:3023
Message Queue Structure.
Definition kernel.h:5316
Semaphore structure.
Definition kernel.h:3798
Kernel Spin Lock.
Definition spinlock.h:45
Kernel timeout type.
Definition clock.h:65
Kernel workqueue structure.
Definition kernel.h:4906
A structure used to submit work.
Definition kernel.h:4708
Network buffer pool representation.
Definition net_buf.h:1151
Type used to represent a channel mutable data.
Definition zbus.h:33
k_ticks_t publish_timestamp
Kernel timestamp of the last publish action on this channel.
Definition zbus.h:72
struct net_buf_pool * msg_subscriber_pool
Net buf pool for message subscribers and async listeners.
Definition zbus.h:67
uint32_t publish_count
Number of times data has been published to this channel.
Definition zbus.h:74
int16_t observers_end_idx
Static channel observer list end index.
Definition zbus.h:42
int16_t observers_start_idx
Static channel observer list start index.
Definition zbus.h:37
struct k_sem sem
Access control semaphore.
Definition zbus.h:47
sys_slist_t observers
Channel observer list.
Definition zbus.h:60
Type used to represent a channel.
Definition zbus.h:95
zbus_validator validator
Message validator.
Definition zbus.h:121
void * user_data
User data available to extend zbus features.
Definition zbus.h:115
uint32_t id
Unique numeric channel identifier.
Definition zbus.h:102
struct zbus_channel_data * data
Mutable channel data struct.
Definition zbus.h:124
size_t message_size
Message size.
Definition zbus.h:110
const char * name
Channel name.
Definition zbus.h:98
void * message
Message reference.
Definition zbus.h:107
bool enabled
Enabled flag.
Definition zbus.h:151
Structure used to register runtime observers.
Definition zbus.h:1124
const struct zbus_observer * obs
Definition zbus.h:1126
sys_snode_t node
Definition zbus.h:1125
Type used to represent an observer.
Definition zbus.h:174
enum zbus_observer_type type
Type indication.
Definition zbus.h:180
struct k_fifo * message_fifo
Observer message FIFO.
Definition zbus.h:196
void(* callback)(const struct zbus_channel *chan)
Observer callback function.
Definition zbus.h:190
struct zbus_observer_data * data
Mutable observer data struct.
Definition zbus.h:183
struct k_msgq * queue
Observer message queue.
Definition zbus.h:187
const char * name
Observer name.
Definition zbus.h:177
struct k_work * work
Observer work.
Definition zbus.h:203
Type used to represent a runtime channel.
Definition zbus.h:130
struct zbus_channel channel
Refer to zbus_channel.
Definition zbus.h:132
Iterable sections helpers.