Public Access
- lib/storage_model (host-tested): FAT-safe names, daily Log paths, dates from Log/Capture file names, CleanupPlan by category and age, byte formatting - StorageService does all card I/O on its task: queued Log lines are written in batches each second (dropped while Logs are paused), plus file listing and deletion jobs - Settings > Storage moves into StoragePage: usage, Clean up (category, age with size preview, confirmation), Erase SD card - Clock: local date for Log names - Serial: log <text>, sd list Verified on the device: lines land in /irc/dev/#test/2026-10-02.log with folders created as needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
34 lines
1.2 KiB
C++
34 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace roro {
|
|
|
|
// Ordered by trust: a source can only replace the time set by an equal or less trusted one.
|
|
enum class TimeSource : uint8_t { None, Mesh, Ntp, Gnss };
|
|
|
|
// Wall-clock time on a device with no battery-backed clock: unset until a TimeSource provides
|
|
// it, then advanced from uptime. Stored in UTC; local display uses the POSIX TZ applied globally.
|
|
class ClockModel {
|
|
public:
|
|
// Returns false if a more trusted source already set the time.
|
|
bool set(int64_t utcSeconds, TimeSource source, uint32_t nowMs);
|
|
|
|
bool isSet() const { return source_ != TimeSource::None; }
|
|
TimeSource source() const { return source_; }
|
|
int64_t utcNow(uint32_t nowMs) const;
|
|
|
|
static void applyTimezone(const char* posixTz);
|
|
static std::string formatLocalTime(int64_t utcSeconds); // "HH:MM"
|
|
static std::string formatLocalDate(int64_t utcSeconds); // "YYYY-MM-DD"
|
|
static std::string formatAge(int64_t seconds); // "now", "5 min ago", "3 h ago", "2 d ago"
|
|
|
|
private:
|
|
TimeSource source_ = TimeSource::None;
|
|
int64_t utcAtSet_ = 0;
|
|
uint32_t msAtSet_ = 0;
|
|
};
|
|
|
|
} // namespace roro
|