Compare commits

..

1 Commits

Author SHA1 Message Date
Xuan-Son Nguyen
d97a774641
Merge 44ea8b7b6a into f67c544e16 2026-02-02 21:27:05 +11:00
2 changed files with 5 additions and 4 deletions

View File

@ -467,7 +467,7 @@ static bool flushUploadBuffer(CrossPointWebServer::UploadState& state) {
if (state.bufferPos > 0 && state.file) {
esp_task_wdt_reset(); // Reset watchdog before potentially slow SD write
const unsigned long writeStart = millis();
const size_t written = state.file.write(state.buffer.data(), state.bufferPos);
const size_t written = state.file.write(state.buffer, state.bufferPos);
totalWriteTime += millis() - writeStart;
writeCount++;
esp_task_wdt_reset(); // Reset watchdog after SD write
@ -565,7 +565,7 @@ void CrossPointWebServer::handleUpload(UploadState& state) const {
const size_t space = UploadState::UPLOAD_BUFFER_SIZE - state.bufferPos;
const size_t toCopy = (remaining < space) ? remaining : space;
memcpy(state.buffer.data() + state.bufferPos, data, toCopy);
memcpy(state.buffer + state.bufferPos, data, toCopy);
state.bufferPos += toCopy;
data += toCopy;
remaining -= toCopy;

View File

@ -42,10 +42,11 @@ class CrossPointWebServer {
// 4KB is a good balance: large enough to reduce syscall overhead, small enough
// to keep individual write times short and avoid watchdog issues
static constexpr size_t UPLOAD_BUFFER_SIZE = 4096; // 4KB buffer
std::vector<uint8_t> buffer;
uint8_t* buffer = nullptr;
size_t bufferPos = 0;
UploadState() { buffer.resize(UPLOAD_BUFFER_SIZE); }
UploadState() : buffer(new uint8_t[UPLOAD_BUFFER_SIZE]) {}
~UploadState() { delete[] buffer; }
} upload;
CrossPointWebServer();