#pragma once #include #include #include #include "scan_entry.h" namespace roro { // Writes what Wi-Fi Tools already sees (access points, channel, signal) to a CSV Log, so the user // can track their own Wi-Fi environment over time. One row per access point per logged scan. namespace scanlog { // A CSV field, quoted when it contains a comma, quote or newline. std::string csvField(const std::string& value); // The header row (no trailing newline). std::string header(); // One data row for an access point seen at `timestamp` (a preformatted local time string). std::string row(const std::string& timestamp, const ScanEntry& ap); } // namespace scanlog // Decides when to write a scan to the Log: at most once per interval. class ScanLogThrottle { public: explicit ScanLogThrottle(uint32_t intervalMs) : intervalMs_(intervalMs) {} bool due(uint32_t nowMs) const { return !logged_ || nowMs - lastMs_ >= intervalMs_; } void logged(uint32_t nowMs) { lastMs_ = nowMs; logged_ = true; } void reset() { logged_ = false; } private: uint32_t intervalMs_; uint32_t lastMs_ = 0; bool logged_ = false; }; } // namespace roro