Added Telemetry data report to the App

This commit is contained in:
2025-10-31 21:10:38 +02:00
parent f286abb023
commit a7f1bd1667
13 changed files with 194 additions and 20 deletions

View File

@@ -175,6 +175,52 @@ size_t FileManager::getFileSize(const String& filePath) {
return size;
}
bool FileManager::writeJsonFile(const String& filePath, JsonDocument& doc) {
if (!initializeSD()) {
return false;
}
File file = SD.open(filePath.c_str(), FILE_WRITE);
if (!file) {
LOG_ERROR("Failed to open file for writing: %s", filePath.c_str());
return false;
}
if (serializeJson(doc, file) == 0) {
LOG_ERROR("Failed to write JSON to file: %s", filePath.c_str());
file.close();
return false;
}
file.close();
LOG_DEBUG("JSON file written successfully: %s", filePath.c_str());
return true;
}
bool FileManager::readJsonFile(const String& filePath, JsonDocument& doc) {
if (!initializeSD()) {
return false;
}
File file = SD.open(filePath.c_str(), FILE_READ);
if (!file) {
LOG_ERROR("Failed to open file for reading: %s", filePath.c_str());
return false;
}
DeserializationError error = deserializeJson(doc, file);
file.close();
if (error) {
LOG_ERROR("Failed to parse JSON from file: %s, error: %s",
filePath.c_str(), error.c_str());
return false;
}
LOG_DEBUG("JSON file read successfully: %s", filePath.c_str());
return true;
}
// ════════════════════════════════════════════════════════════════════════════
// HEALTH CHECK IMPLEMENTATION
// ════════════════════════════════════════════════════════════════════════════