File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -636,6 +636,34 @@ the defined channels and observers.
636636 ZBUS_CHAN_DECLARE(acc_chan, version_chan);
637637
638638
639+ Unique channel identifiers
640+ --------------------------
641+
642+ To simplify integrations with external entities, it is possible to assign a unique numeric identifier
643+ to a channel. Users can then retrieve the channel reference by using the identifier with
644+ :c:func: `zbus_chan_from_id `, rather than needing to obtain the reference at compile time with
645+ :c:macro: `ZBUS_CHAN_DECLARE `. Channels using this feature are declared with
646+ :c:func: `ZBUS_CHAN_DEFINE_WITH_ID `.
647+
648+ .. code-block :: c
649+
650+ ZBUS_CHAN_DEFINE_WITH_ID(control_chan, /* Name */
651+ 0x12345678, /* Unique channel identifier */
652+ struct control_msg, /* Message type */
653+ control_validator, /* Validator */
654+ &message_count, /* User data */
655+ ZBUS_OBSERVERS_EMPTY, /* observers */
656+ ZBUS_MSG_INIT(.move = 0) /* Initial value */
657+ );
658+
659+ static void channel_retrieve(void)
660+ {
661+ const struct zbus_channel *chan = zbus_chan_from_id(0x12345678);
662+
663+ ...
664+ }
665+
666+
639667 Iterating over channels and observers
640668=====================================
641669
You can’t perform that action at this time.
0 commit comments