|
Modbus Vault v1.0
|
Implementation of the event bus. More...
#include "event_bus.h"#include "esp_log.h"#include "freertos/FreeRTOS.h"#include "freertos/queue.h"#include "runtime_tasks.h"#include "string.h"Data Structures | |
| struct | subscriber_t |
| Subscriber structure. More... | |
Macros | |
| #define | EVENT_BUS_MAX_SUBSCRIBERS (8U) |
| #define | EVENT_BUS_COUNT_BACKOFF_WATERMARK (5U) |
Functions | |
| static void | event_bus_task (void *parameters_void_ptr) |
| Event bus task. | |
| static void | event_bus_stop_task (void) |
| Stop event bus task. | |
| esp_err_t | event_bus_init (size_t queue_size) |
| Initialize event bus. | |
| bool | event_bus_publish (const event_bus_t *event_ptr) |
| Publish an event. | |
| int8_t | event_bus_subscribe (event_bus_event_t type, event_bus_cb_t cb, void *ctx) |
| Subscribe to event. | |
| bool | event_bus_unsubscribe (int8_t slot) |
| Unsubscribe from event. | |
| void | event_bus_deinit (void) |
| deinitialize event bus | |
Variables | |
| static const char * | TAG = "EVENT_BUS" |
| static TaskHandle_t | event_bus_task_handle = NULL |
| static QueueHandle_t | event_queue |
| static subscriber_t | subscribers [(8U)] |
| runtime_task_config_t | event_bus_task_config |
Implementation of the event bus.
| #define EVENT_BUS_COUNT_BACKOFF_WATERMARK (5U) |
Task backoff when queue reach watermark
| #define EVENT_BUS_MAX_SUBSCRIBERS (8U) |
Maximum possible subscribers
| esp_err_t event_bus_init | ( | size_t | queue_size | ) |
Initialize event bus.
| queue_size | Size of the event queue |
| 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 |
| bool event_bus_publish | ( | const event_bus_t * | event_ptr | ) |
Publish an event.
Publish an event by queue it to the event bus queue
| event_ptr | Pointer to an event |
| int8_t event_bus_subscribe | ( | event_bus_event_t | type, |
| event_bus_cb_t | cb, | ||
| void * | ctx | ||
| ) |
Subscribe to event.
| type | Event type |
| cb | Callback for when event happens |
| ctx | Context for the callback |
< Maximum possible subscribers
|
static |
Event bus task.
Loops over subscribers calling them if their event match current one
| parameters_void_ptr | Void pointer to task parameters |
< Maximum possible subscribers
< Task backoff when queue reach watermark
| bool event_bus_unsubscribe | ( | int8_t | slot | ) |
Unsubscribe from event.
| slot | Subscription slot number |
< Maximum possible subscribers
| runtime_task_config_t event_bus_task_config |
Event bus task configuration structure
|
static |
Event bus task handle
|
static |
Event bus queue handle
|
static |
Event bus subscribers list
|
static |
Event bus TAG name