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

System hooks for internal business logic. More...

IP layer events

These handlers are dispatched automatically by the framework when the corresponding IP-level event occurs.

typedef esp_err_t(* eif_handler_ip_t) (void)
 Prototype for network IP lifecycle event handlers.
 
esp_err_t eif_register_handler_ip_got (eif_handler_ip_t handler)
 Register a handler for the IP_EVENT_STA_GOT_IP. More...
 
esp_err_t eif_register_handler_ip_lost (eif_handler_ip_t handler)
 Register a handler for the IP_EVENT_STA_LOST_IP. More...
 

Detailed Description

These functions are the primary interface for linking the final product's business logic with system-wide lifecycle events. They allow the application to execute specific tasks in direct response to internal state transitions, hardware updates, and subsystem status changes.

Note
Before calling any function in this group, eif_core_initialize() must be executed exactly once, and all calls must take place prior to eif_wifi_initialize().

Examples:
#include <esp_err.h>
#include <esp_iot_framework_core.h>
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
// Further code...
ESP_ERROR_CHECK(eif_wifi_initialize());
}
esp_err_t eif_core_initialize(void)
Initializes the CORE of the framework.
esp_err_t eif_wifi_initialize(void)
Launch the Wi-Fi subsystem and automated network services.

Function Documentation

◆ eif_register_handler_ip_got()

esp_err_t eif_register_handler_ip_got ( eif_handler_ip_t  handler)

Registers a callback for processing network layer events. It is the primary trigger point that executes automatically as soon as the station secures a valid IP lease from the DHCP server.

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>
#include <esp_iot_framework_core_ext.h>
esp_err_t ip_got_hanlder(void) {
// Initialize HTTP server or cloud telemetry tasks safely here
return ESP_OK;
}
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_register_handler_ip_got(ip_got_hanlder));
// Further code...
}
esp_err_t eif_register_handler_ip_got(eif_handler_ip_t handler)
Register a handler for the IP_EVENT_STA_GOT_IP.

◆ eif_register_handler_ip_lost()

esp_err_t eif_register_handler_ip_lost ( eif_handler_ip_t  handler)
Warning
Due to the limitations of the SDK, the framework automatically calls this handler at event WIFI_EVENT_STA_DISCONNECTED, since it is equivalent to IP_EVENT_STA_LOST_IP. If IP_EVENT_STA_LOST_IP is separate, the handler will be called twice.

Registers a callback for processing network layer events. It executes automatically when the station drops its Wi-Fi connection, the AP kicks the client, or the DHCP lease expires.

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>
#include <esp_iot_framework_core_ext.h>
esp_err_t ip_lost_hanlder(void) {
// Gracefully put cloud communication tasks to sleep
return ESP_OK;
}
void app_main(void) {
ESP_ERROR_CHECK(eif_core_initialize());
ESP_ERROR_CHECK(eif_register_handler_ip_lost(ip_lost_hanlder));
// Further code...
}
esp_err_t eif_register_handler_ip_lost(eif_handler_ip_t handler)
Register a handler for the IP_EVENT_STA_LOST_IP.