[ota] Fix OTA handshake failure by flushing pending writes before blocking read

Add delay(0) after switching to blocking mode in handle_data_() to
flush any pending non-blocking writes (the feature ACK byte) before
entering the blocking read loop. lwIP may not transmit data written
in non-blocking mode until the task yields.
This commit is contained in:
J. Nick Koston
2026-04-04 17:46:58 -10:00
parent 4d2062282e
commit bf39dfef6a
@@ -283,6 +283,11 @@ void ESPHomeOTAComponent::handle_data_() {
this->client_->setsockopt(SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
this->client_->setblocking(true);
// Yield to flush any pending non-blocking writes (e.g. the feature ACK byte)
// before entering the blocking data transfer. lwIP may not transmit data
// written in non-blocking mode until the task yields.
delay(0);
// Acknowledge auth OK - 1 byte
this->write_byte_(ota::OTA_RESPONSE_AUTH_OK);