fix(FileManager,Logging): day-rotated SD logs + boot reset-reason reporting

SD logging was a silent no-op on fresh cards: appendLine() opened /logs/vesper.log
in FILE_APPEND without ever creating the /logs directory first. FileManager now
exposes appendLogLine(), which creates the directory, rotates to YYYY-MM-DD.log
files, and prunes oldest files once a 512KB total budget is exceeded.

LoggingHandler gains logs.list / logs.download commands (chunked, paginated) so
SD logs can be pulled off a device remotely for offline-device troubleshooting.

Telemetry now captures esp_reset_reason() at boot and classifies it as a fault
(panic/watchdog/brownout) or an expected reset (power-on/software/deep sleep).
CommunicationRouter reports it once MQTT connects: faults go to status/alerts,
expected resets go to status/info (type: boot_reason). MQTTDriver gained a
setOnConnectCallback hook to support this.

F-045, F-046, F-048 in the feature catalog.
This commit is contained in:
2026-07-15 00:04:21 +03:00
parent 399b4d056c
commit 2b4fd7c5b0
16 changed files with 419 additions and 22 deletions
+11
View File
@@ -54,6 +54,7 @@
#define TELEMETRY_HPP
#include <Arduino.h>
#include <esp_system.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "../Logging/Logging.hpp"
@@ -92,6 +93,9 @@ private:
// Pause flag for OTA freeze mode
volatile bool isPaused = false;
// Reset reason, captured once at begin()
esp_reset_reason_t resetReason = ESP_RST_UNKNOWN;
public:
// Initialization
void begin();
@@ -135,6 +139,13 @@ public:
// Boot log
void logBootEvent(uint32_t bootTimestamp);
// Reset reason (captured once at begin(), before anything else can crash again)
esp_reset_reason_t getResetReason() const { return resetReason; }
// True if the reset reason indicates a fault (panic, watchdog, brownout) rather
// than an expected reset (power-on, software reset/OTA, deep sleep wake).
bool isFaultReset() const;
String getResetReasonString() const;
// Data collection (future expansion)
void logTemperature(float temperature);
void logVibration(float vibration);