1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-04 19:03:47 +01:00

Merge branch 'api_reads' into integration

This commit is contained in:
J. Nick Koston
2025-06-18 19:24:32 +02:00

View File

@@ -274,12 +274,21 @@ APIError APINoiseFrameHelper::init() {
} }
/// Run through handshake messages (if in that phase) /// Run through handshake messages (if in that phase)
APIError APINoiseFrameHelper::loop() { APIError APINoiseFrameHelper::loop() {
APIError err = state_action_(); // During handshake phase, process as many actions as possible until we can't progress
if (err != APIError::OK && err != APIError::WOULD_BLOCK) { // socket_->ready() stays true until next main loop, but state_action() will return
return err; // WOULD_BLOCK when no more data is available to read
while (state_ != State::DATA && this->socket_->ready()) {
APIError err = state_action_();
if (err != APIError::OK && err != APIError::WOULD_BLOCK) {
return err;
}
if (err == APIError::WOULD_BLOCK) {
break;
}
} }
if (!this->tx_buf_.empty()) { if (!this->tx_buf_.empty()) {
err = try_send_tx_buf_(); APIError err = try_send_tx_buf_();
if (err != APIError::OK && err != APIError::WOULD_BLOCK) { if (err != APIError::OK && err != APIError::WOULD_BLOCK) {
return err; return err;
} }