esp_iot_framework  v0.1.0-alpha
© 2026 AmakeSasha, distributed under a license Apache-2.0
Event Handlers

System hooks for application business logic. More...

Typedefs

typedef esp_err_t(* eif_handler_system_t) (void)
 Prototype for system-level lifecycle event handlers.
 

Functions

esp_err_t eif_register_handler_system_reboot (eif_handler_system_t handler)
 Register a handler for the system reboot event. More...
 

Detailed Description

These functions are the primary interface for linking the final product's business logic with system lifecycle events. They allow the application to execute specific tasks in direct response to internal state changes.

Function Documentation

◆ eif_register_handler_system_reboot()

esp_err_t eif_register_handler_system_reboot ( eif_handler_system_t  handler)

This function hooks a custom handler into the system teardown process. It is the final safety net that triggers right before the system reset, allowing you to "park" your hardware or commit last-second logs.

Warning
The handler runs within a dedicated reboot task with a limited stack size (CONFIG_EIF_REBOOT_TASK_STACK_SIZE). Avoid deep recursion or allocation of a large amount of memory (stack or heap).
Note
Before this handler runs, the framework will automatically trigger the "IP Lost" (registered via eif_register_handler_ip_lost(), ESP-IDF event: IP_EVENT_STA_LOST_IP) event and disable the Wi-Fi stack. This function must be called after eif_core_initialize().
Warning
This registration is not cumulative. Any previously registered handler for this event will be overwritten. Only the most recent assignment is stored and executed by the CORE.
Parameters
handlerPointer to the function to execute. Cannot be NULL.
Returns
  • ESP_OK: Handler registered successfully.
  • ESP_ERR_INVALID_ARG: The handler pointer is NULL.

Example of use:

#include <esp_err.h>
#include <esp_iot_framework_core.h>
esp_err_t my_reboot_logic(void) {
// Emergency state save or hardware shutdown
return ESP_OK;
}
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_register_handler_system_reboot(my_reboot_logic));
// Further code...
}
esp_err_t eif_core_initialize(void)
Initializes the CORE of the framework.
esp_err_t eif_register_handler_system_reboot(eif_handler_system_t handler)
Register a handler for the system reboot event.