mirror of
https://github.com/esphome/esphome.git
synced 2025-08-07 02:47:47 +00:00
cleanup
This commit is contained in:
parent
bc63d246c8
commit
92f6f3ac0d
@ -151,21 +151,6 @@ void OTARequestHandler::handleUpload(AsyncWebServerRequest *request, const Strin
|
||||
if (len > 0) {
|
||||
auto *backend = static_cast<ota::OTABackend *>(this->ota_backend_);
|
||||
|
||||
// Feed watchdog and yield periodically to prevent timeout during OTA
|
||||
// Flash writes can be slow, especially for large chunks
|
||||
static uint32_t last_ota_yield = 0;
|
||||
static uint32_t ota_chunks_written = 0;
|
||||
uint32_t now = millis();
|
||||
ota_chunks_written++;
|
||||
|
||||
// Yield more frequently during OTA - every 25ms or every 2 chunks
|
||||
if (now - last_ota_yield > 25 || ota_chunks_written >= 2) {
|
||||
// Don't log during yield - logging itself can cause delays
|
||||
vTaskDelay(2); // Let other tasks run for 2 ticks
|
||||
last_ota_yield = now;
|
||||
ota_chunks_written = 0;
|
||||
}
|
||||
|
||||
auto result = backend->write(data, len);
|
||||
if (result != ota::OTA_RESPONSE_OK) {
|
||||
ESP_LOGE(TAG, "OTA write failed: %d", result);
|
||||
|
@ -202,12 +202,6 @@ esp_err_t AsyncWebServer::request_post_handler(httpd_req_t *r) {
|
||||
}
|
||||
});
|
||||
|
||||
// Track time to yield periodically
|
||||
uint32_t last_yield = millis();
|
||||
static constexpr uint32_t YIELD_INTERVAL_MS = 50; // Yield every 50ms
|
||||
uint32_t chunks_processed = 0;
|
||||
static constexpr uint32_t CHUNKS_PER_YIELD = 5; // Also yield every 5 chunks
|
||||
|
||||
while (remaining > 0) {
|
||||
size_t to_read = std::min(remaining, CHUNK_SIZE);
|
||||
int recv_len = httpd_req_recv(r, chunk_buf.get(), to_read);
|
||||
@ -221,16 +215,6 @@ esp_err_t AsyncWebServer::request_post_handler(httpd_req_t *r) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
// Yield periodically to prevent watchdog timeout
|
||||
chunks_processed++;
|
||||
uint32_t now = millis();
|
||||
if (now - last_yield > YIELD_INTERVAL_MS || chunks_processed >= CHUNKS_PER_YIELD) {
|
||||
// Don't log during yield - logging itself can cause delays
|
||||
vTaskDelay(2); // Yield for 2 ticks to give more time to other tasks
|
||||
last_yield = now;
|
||||
chunks_processed = 0;
|
||||
}
|
||||
|
||||
// Log received vs requested - only log every 100KB to reduce overhead
|
||||
static size_t bytes_logged = 0;
|
||||
bytes_logged += recv_len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user