3 Commits

Author SHA1 Message Date
Yurii
b70c212235 fix: filtering fake data from ds18b20 (#217) 2026-01-23 00:19:03 +03:00
Yurii
781b2a1f9c chore: bump pioarduino/platform-espressif32 from 3.3.5 to 3.3.6 2026-01-23 00:17:30 +03:00
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
2 changed files with 39 additions and 6 deletions

View File

@@ -25,8 +25,12 @@ lib_deps =
gyverlibs/FileData@^1.0.3 gyverlibs/FileData@^1.0.3
gyverlibs/GyverPID@^3.3.2 gyverlibs/GyverPID@^3.3.2
gyverlibs/GyverBlinker@^1.1.1 gyverlibs/GyverBlinker@^1.1.1
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg pstolarz/OneWireNg@^0.14.1
;milesburton/DallasTemperature@^4.0.5
https://github.com/Laxilef/Arduino-Temperature-Control-Library#fix_85c
laxilef/TinyLogger@^1.1.1 laxilef/TinyLogger@^1.1.1
lib_ignore =
paulstoffregen/OneWire
build_type = ${secrets.build_type} build_type = ${secrets.build_type}
build_flags = build_flags =
-mtext-section-literals -mtext-section-literals
@@ -73,7 +77,7 @@ platform_packages = ${env.platform_packages}
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
nrwiersma/ESP8266Scheduler@^1.2 nrwiersma/ESP8266Scheduler@^1.2
lib_ignore = lib_ignore = ${env.lib_ignore}
extra_scripts = extra_scripts =
post:tools/build.py post:tools/build.py
build_type = ${env.build_type} build_type = ${env.build_type}
@@ -92,14 +96,14 @@ 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.35/platform-espressif32.zip platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/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 =
${env.lib_deps} ${env.lib_deps}
laxilef/ESP32Scheduler@^1.0.1 laxilef/ESP32Scheduler@^1.0.1
nimble_lib = h2zero/NimBLE-Arduino@2.3.7 nimble_lib = h2zero/NimBLE-Arduino@2.3.7
lib_ignore = lib_ignore = ${env.lib_ignore}
extra_scripts = extra_scripts =
post:tools/esp32.py post:tools/esp32.py
post:tools/build.py post:tools/build.py

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);
}
}; };