Move host wake_loop_threadsafe from application.cpp to wake.cpp

This commit is contained in:
J. Nick Koston
2026-04-04 10:53:15 -10:00
parent d3586c76ba
commit 843b63edb4
2 changed files with 14 additions and 13 deletions
+1 -12
View File
@@ -676,18 +676,7 @@ void Application::setup_wake_loop_threadsafe_() {
}
}
void wake_loop_threadsafe() {
// Wakes up lwip_select() in main loop by writing to connected loopback socket
if (App.wake_socket_fd_ >= 0) {
const char dummy = 1;
// Non-blocking send - if it fails (unlikely), select() will wake on timeout anyway
// No error checking needed: we control both ends of this loopback socket.
// This is safe to call from FreeRTOS tasks - send() is thread-safe in lwip
// Socket is already connected to loopback address, so send() is faster than sendto()
lwip_send(App.wake_socket_fd_, &dummy, 1, 0);
}
}
#endif // host wake_loop_threadsafe
#endif // USE_SOCKET_SELECT_SUPPORT
void Application::get_build_time_string(std::span<char, BUILD_TIME_STR_SIZE> buffer) {
ESPHOME_strncpy_P(buffer.data(), ESPHOME_BUILD_TIME_STR, buffer.size());
+13 -1
View File
@@ -84,6 +84,18 @@ void wakeable_delay(uint32_t ms) {
#endif // USE_RP2040
// Host platform wake_loop_threadsafe() is in application.cpp (needs App.wake_socket_fd_)
// === Host (UDP loopback socket) ===
#ifdef USE_SOCKET_SELECT_SUPPORT
#include "esphome/core/application.h"
#include <lwip/sockets.h>
void wake_loop_threadsafe() {
// Wakes up lwip_select() in main loop by writing to connected loopback socket
if (App.wake_socket_fd_ >= 0) {
const char dummy = 1;
lwip_send(App.wake_socket_fd_, &dummy, 1, 0);
}
}
#endif // USE_SOCKET_SELECT_SUPPORT
} // namespace esphome