11#include "../../include/SDCard.hpp"
13#include "TimeStamp.hpp"
14#include "MQTTMailer.hpp"
35 std::string filename =
"";
36 std::string separator =
";";
42 bool file_open =
false;
68 this->filename = filename;
85 std::string filetype){
87 this->filename =
prefix +
"_" +
88 to_string(month) +
"-" +
89 to_string(day) +
"-" +
90 to_string(year) +
"." + filetype;
116 string filetype=
"csv");
131 if(filename ==
"")
return NULL;
132 this->fp = (sd.
open(this->filename.c_str(),
"r"));
133 this->file_open =
true;
141 this->fp = sd.
open(filename.c_str(),
"r");
142 this->file_open =
true;
150 this->file_open =
false;
Implements an interface for using SPI, SDLogger, for reading and writing to files on an SD card.
const bool USB_DEBUG
USB serial debugging enabled.
Definition main.cpp:62
Thin wrapper around ESP32 SD card API.
Definition SDCard.hpp:28
File open(const char *path, const char *mode=FILE_READ, const bool create=false)
Definition SDCard.hpp:92
SDReader provides an interface for opening and reading data from files created using the SDLogger lib...
Definition SDReader.hpp:31
string build_json_page(string filename, long int epoch, long int terminus, vector< string > &data)
Compile collected data into a JSON "page" which can then be published via the MQTT interface.
Definition SDReader.cpp:54
bool initialize_sd_card()
Initialize connection to SD card and return false if no connection established.
Definition SDReader.cpp:114
void set_filename(string filename)
Manually set the filename to access.
Definition SDReader.hpp:100
SDReader(std::string filename)
Constructor initializes SD card and set default file to open.
Definition SDReader.hpp:67
void close_file()
Close the open file.
Definition SDReader.hpp:149
SDReader(std::string prefix, int month, int day, int year, std::string filetype)
Constructor initializes and sets the file name structure.
Definition SDReader.hpp:81
File * open_file()
Open the specified file and get the file pointer.
Definition SDReader.hpp:130
SDReader()
Constructor initializes SD card connection and nothing more.
Definition SDReader.hpp:60
int calculate_page_size(vector< string > &page)
Calculate the size, in bytes, of the current page.
Definition SDReader.cpp:86
std::string read_line()
Read until next newline character into buffer and return as a string.
Definition SDReader.cpp:133
File * open_file(string filename)
Open the specified file from path provided.
Definition SDReader.hpp:140
bool topic_filter_match(vector< string > filter, string target)
Check if any of the filters match the target string return true if one of them does or filter is "",...
Definition SDReader.cpp:27
void read_entry_range_from_files(TimeStamp epoch, TimeStamp terminus, vector< string > topic_filter, int page_length=5, string prefix="log", string filetype="csv")
Retrieve all data within the specified time range, potentially accessing multiple files.
Definition SDReader.cpp:167
void read_entry_range(File f, TimeStamp epoch, TimeStamp terminus, vector< string > topic_filter, int page_length)
Access a single file to retrieve data in time range and publish via MQTT.
Definition SDReader.cpp:224
Definition TimeStamp.hpp:14
int reset_count
number of resets retrieved for NVS
Definition scheduler.hpp:31
PubSubClient mqtt_client
MQTT client object for logging.