|
esp_iot_framework
v0.1.0-alpha
© 2026 AmakeSasha, distributed under a license Apache-2.0
|
Thread lifecycle control and secure task spawn utilities. More...
Functions | |
| esp_err_t | eif_task_common_spawn (TaskHandle_t *const p_handle, const TaskFunction_t f_worker, const char *const p_name, const uint32_t u32_stack, const UBaseType_t u_prio) |
| Common helper for secure FreeRTOS task spawning. More... | |
| esp_err_t | eif_task_reboot_launch (void) |
| Spawns an asynchronous task to execute a system reboot. More... | |
| esp_err_t | eif_task_wifi_test_launch (uint8_t profile_index) |
| Spawns an asynchronous task to execute a Wi-Fi profile test. More... | |
| esp_err_t | eif_task_tls_recreate_launch (void) |
| Spawns an asynchronous task to regenerate TLS credentials. More... | |
| esp_err_t | eif_task_rollback_and_reboot_launch (void) |
| Spawns an asynchronous task to execute a firmware rollback. More... | |
This group establishes a unified, deterministic framework for spawning and managing FreeRTOS tasks within the ecosystem. It enforces strict input verification, runtime state validation, and centralized resource allocation boundaries. By formalizing task initialization paths, this subsystem eliminates generic firmware vulnerabilities such as race conditions during initialization, unhandled allocation failures, and orphan tasks causing heap fragmentation.
eif_core_initialize() must be executed exactly once.| esp_err_t eif_task_common_spawn | ( | TaskHandle_t *const | p_handle, |
| const TaskFunction_t | f_worker, | ||
| const char *const | p_name, | ||
| const uint32_t | u32_stack, | ||
| const UBaseType_t | u_prio | ||
| ) |
This function provides a standardized mechanism to initialize FreeRTOS tasks. It sequential-validates input arguments, ensures protection against double spawning via the task handle state, and handles memory exhaustion failures safely.
p_handle argument must point to a persistent variable (typically a module-scoped static) to maintain double-spawn protection. Once the task finishes execution or triggers a delete, the underlying task handle variable must be set back to NULL to allow future respawns.| p_handle | Pointer to the TaskHandle_t variable. If the pointed handle is already initialized (not NULL), the function returns ESP_ERR_INVALID_STATE. |
| f_worker | Task function (worker). |
| p_name | Task name string for debugging and identification. |
| u32_stack | Stack size in bytes. |
| u_prio | Task priority. |
ESP_OK: Task created successfully.ESP_ERR_INVALID_ARG: The pointer p_handle, f_worker or p_name is NULL.ESP_ERR_INVALID_STATE: Task handle is already in use (task already exists).ESP_ERR_NO_MEM: Memory could not be allocated due to the lack of an empty block of the required size.Example of use (but it's better to use EIF_TASK_LAUNCH macro):
Example of use (without double-call protection, but it's better to use EIF_TASK_LAUNCH macro):
| esp_err_t eif_task_reboot_launch | ( | void | ) |
Spawns an asynchronous task to execute a system reboot.
ESP_OK: Task created successfully and added to the FreeRTOS scheduler.ESP_ERR_INVALID_ARG: Internal error. One of the mandatory arguments is passed as a NULL pointer.ESP_ERR_INVALID_STATE: The task handle is already active, meaning this task is already running.ESP_ERR_NO_MEM: Memory could not be allocated due to the lack of an empty block of the required size. | esp_err_t eif_task_wifi_test_launch | ( | uint8_t | profile_index | ) |
Spawns an asynchronous task to execute a Wi-Fi profile test.
| profile_index | The index of the Wi-Fi profile under test. Must be from 0 to number of Wi-Fi profiles stored in the system. It is set using eif_set_wifi_profiles_count(). |
ESP_OK: Task created successfully and added to the FreeRTOS scheduler.ESP_ERR_INVALID_ARG: Internal error. One of the mandatory arguments is passed as a NULL pointer.ESP_ERR_INVALID_STATE: The task handle is already active, meaning this task is already running.ESP_ERR_NO_MEM: Memory could not be allocated due to the lack of an empty block of the required size. | esp_err_t eif_task_tls_recreate_launch | ( | void | ) |
CONFIG_EIF_ENABLE_TLS flag in Kconfig to useSpawns an asynchronous task to regenerate TLS credentials.
ESP_OK: Task created successfully and added to the FreeRTOS scheduler.ESP_ERR_INVALID_ARG: Internal error. One of the mandatory arguments is passed as a NULL pointer.ESP_ERR_INVALID_STATE: The task handle is already active, meaning this task is already running.ESP_ERR_NO_MEM: Memory could not be allocated due to the lack of an empty block of the required size. | esp_err_t eif_task_rollback_and_reboot_launch | ( | void | ) |
Spawns an asynchronous task to execute a firmware rollback.
ESP_OK: Task created successfully and added to the FreeRTOS scheduler.ESP_ERR_INVALID_ARG: Internal error. One of the mandatory arguments is passed as a NULL pointer.ESP_ERR_INVALID_STATE: The task handle is already active, meaning this task is already running.ESP_ERR_NO_MEM: Memory could not be allocated due to the lack of an empty block of the required size.