zbus: Add message bus subsystem to Zephyr
Add zbus message bus as a Zephyr subsystem. No message bus or communication abstraction other than the usual (message queues, mailboxes, etc.) enabled developers to implement event-driven systems in Zephyr quickly. Zbus would fill that gap by providing the community with a lightweight and flexible message bus. The implementation tries to be closest as possible to the existing ones. We use the claim/finish approach, and the API for publishing and reading channels are similar in message queues. Zbus is about channels, messages, and observers. Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
This commit is contained in:
parent
47d09c04af
commit
b8ecbfaa57
14 changed files with 1411 additions and 0 deletions
27
subsys/zbus/zbus_iterable_sections.c
Normal file
27
subsys/zbus/zbus_iterable_sections.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Rodrigo Peixoto <rodrigopex@gmail.com>
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <zephyr/logging/log.h>
|
||||
#include <zephyr/zbus/zbus.h>
|
||||
LOG_MODULE_DECLARE(zbus, CONFIG_ZBUS_LOG_LEVEL);
|
||||
|
||||
bool zbus_iterate_over_channels(bool (*iterator_func)(const struct zbus_channel *chan))
|
||||
{
|
||||
STRUCT_SECTION_FOREACH(zbus_channel, chan) {
|
||||
if (!(*iterator_func)(chan)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool zbus_iterate_over_observers(bool (*iterator_func)(const struct zbus_observer *obs))
|
||||
{
|
||||
STRUCT_SECTION_FOREACH(zbus_observer, obs) {
|
||||
if (!(*iterator_func)(obs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue