How to pass variables between components except event handlers?
Posted: Fri Sep 22, 2023 10:37 am
Hello!
I'm new to C and ESP-IDF. I have a project that has app_main.c and a components directory consisting of components
components
-- wifi
------wifi.h
------wifi.c
------CMakeList.txt
-- ethernet
------ethernet.h
------ethernet.c
------CMakeList.txt
-- webserver
------webserver.h
------webserver.c
------CMakeList.txt
-- ntc
------ntc.h
------ntc.c
------CMakeList.txt
Each component includes only those header files that are necessary for its operability (ntc will include only files for working with ADC, and the webserver - only for working with the webserver)
I register (calling functions) these components in the file app_main
(Maybe I'm doing it wrong)
Now, to transfer data from the ADC reading task, I use esp_event library
ntc.c
app_main
Maybe there is a way how to transfer data between components, except in events?
However, in what way is it preferable to transfer data between application components?
I'm new to C and ESP-IDF. I have a project that has app_main.c and a components directory consisting of components
components
-- wifi
------wifi.h
------wifi.c
------CMakeList.txt
-- ethernet
------ethernet.h
------ethernet.c
------CMakeList.txt
-- webserver
------webserver.h
------webserver.c
------CMakeList.txt
-- ntc
------ntc.h
------ntc.c
------CMakeList.txt
Each component includes only those header files that are necessary for its operability (ntc will include only files for working with ADC, and the webserver - only for working with the webserver)
I register (calling functions) these components in the file app_main
Code: Select all
init_wifi();
init_ethernet();
init_ntc();
init_webserver();
Now, to transfer data from the ADC reading task, I use esp_event library
ntc.c
Code: Select all
esp_err_t err = esp_event_post(APP_EVENTS, S_ADC_GOT_TEMP, &data, sizeof(data), portMAX_DELAY);
Code: Select all
ESP_ERROR_CHECK(esp_event_handler_register(APP_EVENTS, S_ADC_GOT_TEMP, adc_got_temp_event_handler, NULL));
Maybe there is a way how to transfer data between components, except in events?
However, in what way is it preferable to transfer data between application components?