mirror of
https://github.com/esphome/esphome.git
synced 2025-08-06 18:37:47 +00:00
cleanup
This commit is contained in:
parent
e01d16ce82
commit
ca203bff9b
@ -7,6 +7,7 @@
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include "esp_tls_crypto.h"
|
||||
#include <esp_task_wdt.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "web_server_idf.h"
|
||||
@ -143,7 +144,7 @@ esp_err_t AsyncWebServer::request_post_handler(httpd_req_t *r) {
|
||||
std::string full_boundary = "--" + boundary;
|
||||
ESP_LOGVV(TAG, "Initializing multipart reader with full boundary: '%s'", full_boundary.c_str());
|
||||
MultipartReader reader(full_boundary);
|
||||
static constexpr size_t CHUNK_SIZE = 1024;
|
||||
static constexpr size_t CHUNK_SIZE = 1460; // Match Arduino AsyncWebServer buffer size
|
||||
// IMPORTANT: chunk_buf is reused for each chunk read from the socket.
|
||||
// The multipart parser will pass pointers into this buffer to callbacks.
|
||||
// Those pointers are only valid during the callback execution!
|
||||
@ -204,6 +205,9 @@ esp_err_t AsyncWebServer::request_post_handler(httpd_req_t *r) {
|
||||
}
|
||||
});
|
||||
|
||||
// Track chunks for watchdog feeding
|
||||
int chunks_processed = 0;
|
||||
|
||||
while (remaining > 0) {
|
||||
size_t to_read = std::min(remaining, CHUNK_SIZE);
|
||||
int recv_len = httpd_req_recv(r, chunk_buf.get(), to_read);
|
||||
@ -226,6 +230,12 @@ esp_err_t AsyncWebServer::request_post_handler(httpd_req_t *r) {
|
||||
}
|
||||
|
||||
remaining -= recv_len;
|
||||
|
||||
// Feed watchdog every 10 chunks (~14KB with 1460 byte chunks)
|
||||
chunks_processed++;
|
||||
if (chunks_processed % 10 == 0) {
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
// Final cleanup - send final signal if upload was in progress
|
||||
|
Loading…
x
Reference in New Issue
Block a user