ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
lwip_fast_select.h File Reference

Go to the source code of this file.

Functions

void esphome_lwip_fast_select_init (void)
 Initialize fast select — must be called from the main loop task during setup().
 
bool esphome_lwip_socket_has_data (int fd)
 Check if a LwIP socket has data ready via direct rcvevent read (~215 ns per socket).
 
void esphome_lwip_hook_socket (int fd)
 Hook a socket's netconn callback to notify the main loop task on receive events.
 
void esphome_lwip_wake_main_loop (void)
 Wake the main loop task from another FreeRTOS task — costs <1 us.
 
void esphome_lwip_wake_main_loop_from_isr (int *px_higher_priority_task_woken)
 Wake the main loop task from an ISR — costs <1 us.
 
void esphome_lwip_wake_main_loop_any_context (void)
 Wake the main loop task from any context (ISR, thread, or main loop).
 

Function Documentation

◆ esphome_lwip_fast_select_init()

void esphome_lwip_fast_select_init ( void )

Initialize fast select — must be called from the main loop task during setup().

Saves the current task handle for xTaskNotifyGive() wake notifications.

Definition at line 180 of file lwip_fast_select.c.

◆ esphome_lwip_hook_socket()

void esphome_lwip_hook_socket ( int fd)

Hook a socket's netconn callback to notify the main loop task on receive events.

Wraps the original event_callback with one that also calls xTaskNotifyGive(). Must be called from the main loop after socket creation.

Definition at line 209 of file lwip_fast_select.c.

◆ esphome_lwip_socket_has_data()

bool esphome_lwip_socket_has_data ( int fd)

Check if a LwIP socket has data ready via direct rcvevent read (~215 ns per socket).

Uses lwip_socket_dbg_get_socket() — a direct array lookup without the refcount that get_socket()/done_socket() uses. Safe because the caller owns the socket lifetime: both has_data reads and socket close/unregister happen on the main loop thread.

Definition at line 197 of file lwip_fast_select.c.

◆ esphome_lwip_wake_main_loop()

void esphome_lwip_wake_main_loop ( void )

Wake the main loop task from another FreeRTOS task — costs <1 us.

NOT ISR-safe — must only be called from task context.

Definition at line 226 of file lwip_fast_select.c.

◆ esphome_lwip_wake_main_loop_any_context()

void esphome_lwip_wake_main_loop_any_context ( void )

Wake the main loop task from any context (ISR, thread, or main loop).

ESP32-only: uses xPortInIsrContext() to detect ISR context. LibreTiny lacks IRAM_ATTR support needed for ISR-safe paths.

Definition at line 245 of file lwip_fast_select.c.

◆ esphome_lwip_wake_main_loop_from_isr()

void esphome_lwip_wake_main_loop_from_isr ( int * px_higher_priority_task_woken)

Wake the main loop task from an ISR — costs <1 us.

ISR-safe variant using vTaskNotifyGiveFromISR().

Parameters
px_higher_priority_task_wokenSet to pdTRUE if a context switch is needed.

Definition at line 234 of file lwip_fast_select.c.