1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-16 18:22:22 +01:00

Optimize socket operations by checking readiness in the main loop (#8918)

This commit is contained in:
J. Nick Koston
2025-05-28 18:16:37 -05:00
committed by GitHub
parent ffc66f539f
commit 43e88af28a
13 changed files with 386 additions and 55 deletions

View File

@@ -13,6 +13,7 @@
#include "api_noise_context.h"
#include "esphome/components/socket/socket.h"
#include "esphome/core/application.h"
namespace esphome {
namespace api {
@@ -90,6 +91,8 @@ class APIFrameHelper {
virtual uint8_t frame_header_padding() = 0;
// Get the frame footer size required by this protocol
virtual uint8_t frame_footer_size() = 0;
// Check if socket has data ready to read
bool is_socket_ready() const { return socket_ != nullptr && socket_->ready(); }
protected:
// Struct for holding parsed frame data