Event-driven architecture in Zephyr

Jeff Langballe <Jeff.langballe@...>

Hi all,


I’m trying to implement an event driven architecture within Zephyr. My goal is to have multiple event handlers trigger on each event. ex. power monitor emits a “low battery” event -> UI thread receives this and sets an LED pattern, cloud thread receives and pushes a warning, another subscriber shuts down some outputs, another subscriber does logging, etc.


Zephyr doesn’t seem to have any explicit mechanisms built in for this. I’ve tried working with message queues and poll signals but they lend themselves more to “one-to-one” communication instead of “one-to-many”. I’ve also used Nordic’s Event Manager library which has the exact interface I’m looking for but gave me trouble with lack of event priority and lack of concurrency for event handlers. For example, if I have a lengthy event handler running for a less-important task, it will block other event handlers which may be of higher importance.


What I’d like to know is if there are existing samples that achieve this or a set of recommendations for implementing this within Zephyr. Specifically, what data passing objects (FIFOs, message queues, mailboxes, etc.) from Zephyr are most appropriate for this kind of IPC and do these objects lend themselves nicely to any specific topology (event broker, event mediator, or others). I could also work around the shortcomings of the Nordic library but it would be nice to have a good framework to use as a starting point instead.





Join devel@lists.zephyrproject.org to automatically receive all group messages.