diff --git a/esphome/components/socket/lwip_raw_tcp_impl.cpp b/esphome/components/socket/lwip_raw_tcp_impl.cpp index c320a6714a..35224442ee 100644 --- a/esphome/components/socket/lwip_raw_tcp_impl.cpp +++ b/esphome/components/socket/lwip_raw_tcp_impl.cpp @@ -111,7 +111,7 @@ void socket_delay(uint32_t ms) { // callbacks via pendsv (not hard IRQ), so they execute from flash safely. void socket_wake() { s_socket_woke = true; - // Also set core wake flag so Application::wakeable_delay_() breaks out + // Also set core wake flag so wakeable_delay() breaks out esphome::wake_loop_any_context(); } #endif diff --git a/esphome/core/application.h b/esphome/core/application.h index f4df256a2d..e112984984 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -920,7 +920,7 @@ inline void ESPHOME_ALWAYS_INLINE Application::yield_with_select_(uint32_t delay // Sleep with instant wake via FreeRTOS task notification. // Woken by: callback wrapper (socket data), wake_loop_threadsafe() (background tasks), or timeout. #endif - esphome::wakeable_delay(delay_ms); + esphome::internal::wakeable_delay(delay_ms); } #endif // !USE_SOCKET_SELECT_SUPPORT diff --git a/esphome/core/wake.cpp b/esphome/core/wake.cpp index 46fbcb3c13..c5fc782c25 100644 --- a/esphome/core/wake.cpp +++ b/esphome/core/wake.cpp @@ -29,6 +29,7 @@ volatile bool g_main_loop_woke = false; void IRAM_ATTR wake_loop_any_context() { wake_loop_impl_(); } +namespace internal { void wakeable_delay(uint32_t ms) { if (ms == 0) { delay(0); @@ -37,6 +38,7 @@ void wakeable_delay(uint32_t ms) { g_main_loop_woke = false; esp_delay(ms, []() { return !g_main_loop_woke; }); } +} // namespace internal #endif // USE_ESP8266 @@ -57,6 +59,7 @@ static int64_t alarm_callback_(alarm_id_t id, void *user_data) { return 0; // One-shot } +namespace internal { void wakeable_delay(uint32_t ms) { if (ms == 0) { yield(); @@ -81,6 +84,7 @@ void wakeable_delay(uint32_t ms) { cancel_alarm(alarm); g_main_loop_woke = false; } +} // namespace internal #endif // USE_RP2040 diff --git a/esphome/core/wake.h b/esphome/core/wake.h index ade64f08b6..53b84f084f 100644 --- a/esphome/core/wake.h +++ b/esphome/core/wake.h @@ -61,6 +61,7 @@ inline void wake_loop_any_context() { esphome_lwip_wake_main_loop(); } inline void wake_loop_threadsafe() { esphome_lwip_wake_main_loop(); } +namespace internal { inline void wakeable_delay(uint32_t ms) { if (ms == 0) { yield(); @@ -68,6 +69,7 @@ inline void wakeable_delay(uint32_t ms) { } ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(ms)); } +} // namespace internal // === ESP8266 === #elif defined(USE_ESP8266) @@ -84,8 +86,10 @@ void wake_loop_any_context(); /// Non-ISR: always inline. inline void wake_loop_threadsafe() { wake_loop_impl_(); } +namespace internal { /// Wakeable delay for ESP8266. Defined in wake.cpp. void wakeable_delay(uint32_t ms); +} // namespace internal // === RP2040 === #elif defined(USE_RP2040) @@ -100,8 +104,10 @@ inline void wake_loop_threadsafe() { __sev(); } +namespace internal { /// Delay that can be woken early. Uses hardware timer + __wfe()/__sev(). Defined in wake.cpp. void wakeable_delay(uint32_t ms); +} // namespace internal // === Host (UDP loopback socket) === #else