#pragma once #include #include #include "esp_err.h" /* Storage backend for C-ITS capture. * * Primary : SPI SD card reader (T-Dongle C5 pins). Removable -> pull the card * out and read the CSV on a PC. * Fallback: built-in flash 'storage' FAT partition (works with no card). * * CSV files rotate every 10 minutes; a header line is written on open. */ /* Mount a backend (SD first, flash fallback) and open the first CSV file. * Returns ESP_OK if a usable filesystem is available, ESP_FAIL otherwise * (in which case capture continues to serial only). */ esp_err_t cits_store_init(void); /* Append one CSV record (no newline needed — one is added) and flush * periodically. Safe to call from a single processing task. */ esp_err_t cits_store_log(const char *record); /* Close/flush the current file and start a new one (also called automatically * on the 10-minute boundary). */ void cits_store_rotate(void); /* True if a filesystem (SD or flash) is mounted and logging to it. */ bool cits_store_ready(void); /* Human-readable backend in use ("sd-card" | "flash" | "none"). */ const char *cits_store_source(void); /* Absolute path of the file currently being written. */ const char *cits_store_path(void); /* Total CSV records written since boot. */ uint64_t cits_store_count(void);