mirror of
https://github.com/esphome/esphome.git
synced 2025-09-07 05:42:20 +01:00
Merge branch 'ota_fixes' into integration
This commit is contained in:
@@ -329,8 +329,7 @@ void ESPHomeOTAComponent::handle_data_() {
|
|||||||
ssize_t read = this->client_->read(buf, requested);
|
ssize_t read = this->client_->read(buf, requested);
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
delay(1);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ESP_LOGW(TAG, "Read error, errno %d", errno);
|
ESP_LOGW(TAG, "Read error, errno %d", errno);
|
||||||
@@ -366,8 +365,7 @@ void ESPHomeOTAComponent::handle_data_() {
|
|||||||
this->state_callback_.call(ota::OTA_IN_PROGRESS, percentage, 0);
|
this->state_callback_.call(ota::OTA_IN_PROGRESS, percentage, 0);
|
||||||
#endif
|
#endif
|
||||||
// feed watchdog and give other tasks a chance to run
|
// feed watchdog and give other tasks a chance to run
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,8 +427,7 @@ bool ESPHomeOTAComponent::readall_(uint8_t *buf, size_t len) {
|
|||||||
ssize_t read = this->client_->read(buf + at, len - at);
|
ssize_t read = this->client_->read(buf + at, len - at);
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
delay(1);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ESP_LOGW(TAG, "Error reading %d bytes, errno %d", len, errno);
|
ESP_LOGW(TAG, "Error reading %d bytes, errno %d", len, errno);
|
||||||
@@ -441,8 +438,7 @@ bool ESPHomeOTAComponent::readall_(uint8_t *buf, size_t len) {
|
|||||||
} else {
|
} else {
|
||||||
at += read;
|
at += read;
|
||||||
}
|
}
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
delay(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -460,8 +456,7 @@ bool ESPHomeOTAComponent::writeall_(const uint8_t *buf, size_t len) {
|
|||||||
ssize_t written = this->client_->write(buf + at, len - at);
|
ssize_t written = this->client_->write(buf + at, len - at);
|
||||||
if (written == -1) {
|
if (written == -1) {
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
delay(1);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ESP_LOGW(TAG, "Error writing %d bytes, errno %d", len, errno);
|
ESP_LOGW(TAG, "Error writing %d bytes, errno %d", len, errno);
|
||||||
@@ -469,8 +464,7 @@ bool ESPHomeOTAComponent::writeall_(const uint8_t *buf, size_t len) {
|
|||||||
} else {
|
} else {
|
||||||
at += written;
|
at += written;
|
||||||
}
|
}
|
||||||
App.feed_wdt();
|
this->yield_and_feed_watchdog_();
|
||||||
delay(1);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -493,5 +487,10 @@ void ESPHomeOTAComponent::cleanup_connection_() {
|
|||||||
this->client_connect_time_ = 0;
|
this->client_connect_time_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ESPHomeOTAComponent::yield_and_feed_watchdog_() {
|
||||||
|
App.feed_wdt();
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
#endif
|
#endif
|
||||||
|
@@ -35,6 +35,7 @@ class ESPHomeOTAComponent : public ota::OTAComponent {
|
|||||||
void log_read_error_(const char *what);
|
void log_read_error_(const char *what);
|
||||||
void log_start_(const char *phase);
|
void log_start_(const char *phase);
|
||||||
void cleanup_connection_();
|
void cleanup_connection_();
|
||||||
|
void yield_and_feed_watchdog_();
|
||||||
|
|
||||||
#ifdef USE_OTA_PASSWORD
|
#ifdef USE_OTA_PASSWORD
|
||||||
std::string password_;
|
std::string password_;
|
||||||
|
Reference in New Issue
Block a user