#pragma once #include #include "event_bus.h" #include "service.h" #include "services/clock_service.h" #include "services/radio_service.h" #include "services/storage_service.h" namespace roro { // A LoRa Sniffer Capture (CONTEXT.md: Capture; M3, Q97): every packet the radio receives, as pcap // with LoRaTap headers, in /captures/lora/. Started and stopped by hand; keeps the radio listening // and keeps recording whatever App is open (Q100). class LoraCaptureService : public Service { public: LoraCaptureService(RadioService& radio, StorageService& storage, ClockService& clock, EventBus& bus) : radio_(radio), storage_(storage), clock_(clock), bus_(bus) {} const char* name() const override { return "lora-capture"; } uint32_t tickIntervalMs() const override { return 200; } void tick(uint32_t nowMs) override; std::string start(uint32_t nowMs); // why it can't, or "" void stop(); bool capturing() const { return !path_.empty(); } const std::string& path() const { return path_; } uint32_t packets() const { return packets_; } private: void notify(const std::string& text); RadioService& radio_; StorageService& storage_; ClockService& clock_; EventBus& bus_; std::string path_; uint32_t written_ = 0; // the radio's seq last written uint32_t packets_ = 0; int64_t startUtc_ = 0; // the Clock and millis() when it started: packet times follow from both uint32_t startMs_ = 0; }; } // namespace roro