From e3e76f57b32f2327d5bf5318a35662baab7edc8c Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Thu, 1 Aug 2024 22:54:42 -0700 Subject: [PATCH] more work on ESP events --- CMakeLists.txt | 2 +- include/cfglr_signaler_idf_event.h | 5 +++++ src/cfglr_signal_idf_event.c | 13 ++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 485cc7b..dc7f00a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ set(REQUIRES "") set(SRCS "src/configulator.c") if(${ESP_PLATFORM}) - list(APPEND REQUIRES nvs_flash) + list(APPEND REQUIRES nvs_flash esp_event) list(APPEND SRCS src/cfglr_nvs.c src/cfglr_signal_idf_event.c) endif() diff --git a/include/cfglr_signaler_idf_event.h b/include/cfglr_signaler_idf_event.h index 30faadc..6ca7345 100644 --- a/include/cfglr_signaler_idf_event.h +++ b/include/cfglr_signaler_idf_event.h @@ -1,8 +1,12 @@ #ifndef __IDF_EVENT_H__ #define __IDF_EVENT_H__ +#ifdef ESP_PLATFORM +#include "esp_event.h" #include "configulator.h" +ESP_EVENT_DECLARE_BASE(CFGLR_EVENT_BASE); + uint8_t cfglr_signaler_idf_init(cfglr_signaler_t *signaler, cfglr_handle_t *handle); uint8_t cfglr_signaler_idf_dispatch(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_signal_e sig); @@ -11,3 +15,4 @@ uint8_t cfglr_signaler_idf_dispatch(cfglr_signaler_t *signaler, cfglr_element_t } #endif +#endif diff --git a/src/cfglr_signal_idf_event.c b/src/cfglr_signal_idf_event.c index 3b116c2..c392170 100644 --- a/src/cfglr_signal_idf_event.c +++ b/src/cfglr_signal_idf_event.c @@ -1,10 +1,21 @@ +#include "configulator.h" #include "cfglr_log.h" #include "cfglr_signaler_idf_event.h" +ESP_EVENT_DEFINE_BASE(CFGLR_EVENT_BASE); + #define TAG "CFGLR_SIG_IDF" +const char* cfglr_signal_names[] = { + "CFGLR_SIGNAL_LOADED", + "CFGLR_SIGNAL_CHANGE", + "CFGLR_SIGNAL_DELETE", +}; + uint8_t cfglr_signaler_idf_dispatch(cfglr_signaler_t *signaler, cfglr_element_t *element, cfglr_signal_e sig) { - CFGLR_LOGI(TAG, "Dispatch!: %d", sig); + CFGLR_LOGI(TAG, "dispatch: %s", cfglr_signal_names[sig]); + + esp_event_post(CFGLR_EVENT_BASE, sig, element->data, element->datatype_size, portMAX_DELAY); return 0; }