3 Commits

Author SHA1 Message Date
Konstantin
10ab75c055 feat: dynamic filenames for backup/debug (#207)
* feat: generate dynamic filenames for JSON file downloads (backup and debug) based on hostname and timestamp

* fix: threadsafe getFilename
2025-12-23 11:32:40 +03:00
Yurii
56a8574aba chore: bump version to 1.6.0 2025-12-20 12:06:25 +03:00
Yurii
3adfabdf40 chore: bump pioarduino/platform-espressif32 from 3.3.4 to 3.3.5 2025-12-20 12:06:06 +03:00
2 changed files with 33 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ extra_configs = secrets.default.ini
core_dir = .pio core_dir = .pio
[env] [env]
version = 1.5.6 version = 1.6.0
framework = arduino framework = arduino
lib_deps = lib_deps =
bblanchon/ArduinoJson@^7.4.2 bblanchon/ArduinoJson@^7.4.2
@@ -92,7 +92,7 @@ check_flags = ${env.check_flags}
;platform_packages = ;platform_packages =
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5 ; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip ; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.34/platform-espressif32.zip platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
platform_packages = ${env.platform_packages} platform_packages = ${env.platform_packages}
board_build.partitions = esp32_partitions.csv board_build.partitions = esp32_partitions.csv
lib_deps = lib_deps =

View File

@@ -241,7 +241,17 @@ protected:
doc.shrinkToFit(); doc.shrinkToFit();
this->webServer->sendHeader(F("Content-Disposition"), F("attachment; filename=\"backup.json\"")); char filename[64];
getFilename(filename, sizeof(filename), "backup");
char contentDispositionHeaderValue[128];
snprintf_P(
contentDispositionHeaderValue,
sizeof(contentDispositionHeaderValue),
PSTR("attachment; filename=\"%s\""),
filename
);
this->webServer->sendHeader(F("Content-Disposition"), contentDispositionHeaderValue);
this->bufferedWebServer->send(200, F("application/json"), doc); this->bufferedWebServer->send(200, F("application/json"), doc);
}); });
@@ -839,7 +849,18 @@ protected:
doc.shrinkToFit(); doc.shrinkToFit();
this->webServer->sendHeader(F("Content-Disposition"), F("attachment; filename=\"debug.json\"")); char filename[64];
getFilename(filename, sizeof(filename), "debug");
char contentDispositionHeaderValue[128];
snprintf_P(
contentDispositionHeaderValue,
sizeof(contentDispositionHeaderValue),
PSTR("attachment; filename=\"%s\""),
filename
);
this->webServer->sendHeader(F("Content-Disposition"), contentDispositionHeaderValue);
this->bufferedWebServer->send(200, F("application/json"), doc, true); this->bufferedWebServer->send(200, F("application/json"), doc, true);
}); });
@@ -1046,4 +1067,12 @@ protected:
this->dnsServer->stop(); this->dnsServer->stop();
this->dnsServerEnabled = false; this->dnsServerEnabled = false;
} }
static void getFilename(char* filename, size_t maxSizeFilename, const char* type) {
const time_t now = time(nullptr);
const tm* localNow = localtime(&now);
char localNowValue[20];
strftime(localNowValue, sizeof(localNowValue), PSTR("%Y-%m-%d-%H-%M-%S"), localNow);
snprintf_P(filename, maxSizeFilename, PSTR("%s_%s_%s.json"), networkSettings.hostname, localNowValue, type);
}
}; };