mirror of
https://github.com/esphome/esphome.git
synced 2026-09-15 17:18:40 +00:00
Move host wake_loop_threadsafe from application.cpp to wake.cpp
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user