Event bus component.
More...
#include "esp_err.h"
#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
Event bus component.
- Author
- Abanoub Salah
- Provides lightweight event bus to
- Publish different system events
- Decouple components
- Provide subscribers access to event
◆ EVENT_BUS_TASK_CPU_AFFINITY
| #define EVENT_BUS_TASK_CPU_AFFINITY (0U) |
◆ EVENT_BUS_TASK_NAME
| #define EVENT_BUS_TASK_NAME ("EVENT_BUS") |
◆ EVENT_BUS_TASK_NOTIFY_event_available_BIT
| #define EVENT_BUS_TASK_NOTIFY_event_available_BIT (1U << 1U) |
Task notify for event bit
◆ EVENT_BUS_TASK_NOTIFY_STOP_BIT
| #define EVENT_BUS_TASK_NOTIFY_STOP_BIT (1U << 0U) |
◆ EVENT_BUS_TASK_PRIORITY
| #define EVENT_BUS_TASK_PRIORITY (3U) |
◆ EVENT_BUS_TASK_STACK_DEPTH
| #define EVENT_BUS_TASK_STACK_DEPTH (2024U) |
◆ event_bus_cb_t
| typedef void(* event_bus_cb_t) (const event_bus_t *event, void *ctx) |
Callback for when event trigger
◆ event_bus_event_t
Event bus event type enum.
| Enumerator |
|---|
| EVENT_BUS_EVENT_ERROR | Error event
|
◆ event_bus_init()
| esp_err_t event_bus_init |
( |
size_t |
queue_size | ) |
|
Initialize event bus.
- Parameters
-
| queue_size | Size of the event queue |
- Returns
- esp_err_t Initialize result
- Return values
-
| ESP_OK | Initialize success |
| BLACKBOX_FAIL | Failed to create event task |
| ESP_ERR_INVALID_ARG | Provided invalid argument(s) |
| ESP_ERR_NO_MEM | No available memory for resource allocation |
◆ event_bus_publish()
| bool event_bus_publish |
( |
const event_bus_t * |
event_ptr | ) |
|
Publish an event.
Publish an event by queue it to the event bus queue
- Parameters
-
| event_ptr | Pointer to an event |
- Returns
- bool true on publish false otherwise
◆ event_bus_subscribe()
Subscribe to event.
- Parameters
-
| type | Event type |
| cb | Callback for when event happens |
| ctx | Context for the callback |
- Returns
- int8_t Subscription slot number and '-1' On fail
< Maximum possible subscribers
◆ event_bus_unsubscribe()
| bool event_bus_unsubscribe |
( |
int8_t |
slot | ) |
|
Unsubscribe from event.
- Parameters
-
| slot | Subscription slot number |
- Returns
- true on unsubscription false otherwise
< Maximum possible subscribers