mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-06 11:36:51 +03:00
Update interface_influxdb.cpp
This commit is contained in:
@@ -67,23 +67,21 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
|
|||||||
// Format: #define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S%z"
|
// Format: #define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S%z"
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
||||||
time_t t = mktime(&tm); // t is now your desired time_t
|
|
||||||
|
time_t t = mktime(&tm); // Time in Localtime (looks like timezone is not used by strptime)
|
||||||
|
|
||||||
struct tm * ptm;
|
struct tm * ptm;
|
||||||
ptm = gmtime ( &t );
|
ptm = gmtime ( &t );
|
||||||
time_t utc = mktime(ptm);
|
|
||||||
|
|
||||||
// time_t now;
|
time_t utc = mktime(ptm);
|
||||||
// time(&now);
|
utc = 2*t - utc;
|
||||||
|
|
||||||
char nowTimestamp[21];
|
char nowTimestamp[21];
|
||||||
// pad with zeroes to get nanoseconds
|
|
||||||
// sprintf(nowTimestamp,"%ld000000000", (long) now);
|
|
||||||
// sprintf(nowTimestamp,"%ld000000000", (long) t); // Localtime
|
|
||||||
sprintf(nowTimestamp,"%ld000000000", (long) utc); // UTC
|
sprintf(nowTimestamp,"%ld000000000", (long) utc); // UTC
|
||||||
|
|
||||||
|
|
||||||
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - t: " + std::to_string(t) + ", utc: " + std::to_string(utc));
|
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - t: " + std::to_string(t) + ", utc: " + std::to_string(utc) + ", now: " + std::to_string(now) + ", utc_local: " + std::to_string(utc_local));
|
||||||
// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Test Time Conversion - now: " + std::to_string(now) + ", timestamp: " + std::to_string(t) + "(correct time not used yet)");
|
|
||||||
|
|
||||||
std::string payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
std::string payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
||||||
payload.shrink_to_fit();
|
payload.shrink_to_fit();
|
||||||
|
|||||||
Reference in New Issue
Block a user