Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: zbus: document ZBUS_CHAN_DEFINE_WITH_ID #84348

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/services/zbus/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,34 @@ the defined channels and observers.
ZBUS_CHAN_DECLARE(acc_chan, version_chan);


Unique channel identifiers
--------------------------

To simplify integrations with external entities, it is possible to assign a unique numeric identifier
to a channel. Users can then retrieve the channel reference by using the identifier with
:c:func:`zbus_chan_from_id`, rather than needing to obtain the reference at compile time with
:c:macro:`ZBUS_CHAN_DECLARE`. Channels using this feature are declared with
:c:func:`ZBUS_CHAN_DEFINE_WITH_ID`.

.. code-block:: c

ZBUS_CHAN_DEFINE_WITH_ID(control_chan, /* Name */
0x12345678, /* Unique channel identifier */
struct control_msg, /* Message type */
control_validator, /* Validator */
&message_count, /* User data */
ZBUS_OBSERVERS_EMPTY, /* observers */
ZBUS_MSG_INIT(.move = 0) /* Initial value */
);

static void channel_retrieve(void)
{
const struct zbus_channel *chan = zbus_chan_from_id(0x12345678);

...
}


Iterating over channels and observers
=====================================

Expand Down
Loading