32void log_data(std::string topic, std::string message){
35 bool wifi_connected = WiFi.status() == WL_CONNECTED;
39 MQTTMailer instance = MQTTMailer::getInstance();
41 Serial.println(
"\t-> logging to MQTT");
47 Serial.println(
"\t-> logging to SD card");
53 time =
tsp->get_timestamp();
61 Serial.printf(
"[DEBUG] log offset:%i, reset_count:%i, tsp offset:%i\n", log_offset,
reset_count,
tsp->get_offset());
81 std::string date = std::to_string(
tsp->get_month()) +
"-" +
82 std::to_string(
tsp->get_day()) +
"-" +
83 std::to_string(
tsp->get_year());
85 std::string clock_time = std::to_string(
tsp->get_hours()) +
":" +
86 std::to_string(
tsp->get_minutes()) +
":" +
87 std::to_string(
tsp->get_seconds());
89 std::string offset = std::to_string(new_offset);
91 time =
tsb->get_date_time(date, clock_time, offset);
100 Serial.printf(
"[DEBUG] logging \'%s\' | \'%s\' | \'%s\'\n", time.c_str(), topic.c_str(), message.c_str());
103 Serial.println(
"[ERROR] no SD card connected when logging");
Converts MQTTMail objects into viable MQTT messages so that they can be published.
Definition MQTTMailer.hpp:60
void mailMessage(PubSubClient *mqtt_client, std::string topic, std::string message, bool serial_debug=true)
Publish an MQTT message to a topic hosted by a specific broker.
Definition MQTTMailer.cpp:31
#define MAX_COUNT
Definition config.hpp:21
void log_data(std::string topic, std::string message)
Definition logger.hpp:32
int reset_count
number of resets retrieved for NVS
Definition scheduler.hpp:31
TimeStampParser * tsp
parses timestamp strings
Definition logging_util.cpp:53
bool logged_relative_data
relatively accurate timestamp used, last exact timestamp + # of minutes/resets elapsed
Definition logging_util.cpp:39
std::string time_stamp_to_cache
the formatted timestamp to write to non-volatile memory for next reset
Definition logging_util.cpp:42
SDLogger * logger
reads and writes to files
Definition logging_util.cpp:50
bool logging_available
is some logging interface available?
Definition logging_util.cpp:35
TimeStampBuilder * tsb
builds timestamp strings
Definition logging_util.cpp:52
void log_to_sd_file(std::string filename, std::string time, std::string topic, std::string message)
Definition logging_util.cpp:209
int cache_retrieve_log_offset(void)
Definition logging_util.cpp:190
bool absolute_timestamp_available
is an exact/accurate timestamp available?
Definition logging_util.cpp:37
PubSubClient mqtt_client
MQTT client object for logging.