mirror of
https://github.com/esphome/esphome.git
synced 2026-07-11 01:15:33 +00:00
[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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user