|
|
@@ -46,10 +46,8 @@ void InfluxDB_V2_Publish(std::string _key, std::string _content, std::string _ti
|
|
|
|
|
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "InfluxDB_V2_Publish - Key: " + _key + ", Content: " + _content + ", Timestamp: " + _timestamp);
|
|
|
|
|
|
- // Format: #define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S%z"
|
|
|
-
|
|
|
- char nowTimestamp[21];
|
|
|
std::string payload;
|
|
|
+ char nowTimestamp[21];
|
|
|
|
|
|
if (_timestamp.length() > 0)
|
|
|
{
|
|
|
@@ -57,20 +55,22 @@ void InfluxDB_V2_Publish(std::string _key, std::string _content, std::string _ti
|
|
|
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
|
|
time_t t = mktime(&tm); // Time in Localtime (looks like timezone is not used by strptime)
|
|
|
|
|
|
- struct tm * ptm;
|
|
|
- ptm = gmtime ( &t );
|
|
|
- time_t utc = mktime(ptm);
|
|
|
- utc = 2*t - utc; // Take care of timezone (looks difficult, but is easy: t = t + (t - utc), weil t-utc = timezone)
|
|
|
+// struct tm * ptm;
|
|
|
+// ptm = gmtime ( &t );
|
|
|
+// time_t utc = mktime(ptm);
|
|
|
+
|
|
|
+ LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Use handover timestamp: " + _timestamp + " converted GMT timestamp: " + std::to_string(t));
|
|
|
|
|
|
- sprintf(nowTimestamp,"%ld000000000", (long) utc); // UTC
|
|
|
+// utc = 2*t - utc; // Take care of timezone (looks difficult, but is easy: t = t + (t - utc), weil t-utc = timezone)
|
|
|
+// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "time conversion utc after: " + std::to_string(utc));
|
|
|
+
|
|
|
+ sprintf(nowTimestamp,"%ld000000000", (long) t); // UTC
|
|
|
|
|
|
payload = _influxDB_V2_Measurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
|
|
-// payload = _influxDB_V2_Measurement + " " + _key + "=774 " + nowTimestamp;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
payload = _influxDB_V2_Measurement + " " + _key + "=" + _content;
|
|
|
-// payload = _influxDB_V2_Measurement + " " + _key + "=774";
|
|
|
}
|
|
|
|
|
|
payload.shrink_to_fit();
|
|
|
@@ -157,10 +157,10 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
|
|
|
http_config.auth_type = HTTP_AUTH_TYPE_BASIC;
|
|
|
}
|
|
|
|
|
|
- LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "InfluxDBPublish - Key: " + _key + ", Content: " + _content + ", Timestamp: " + _timestamp);
|
|
|
-
|
|
|
- char nowTimestamp[21];
|
|
|
std::string payload;
|
|
|
+ char nowTimestamp[21];
|
|
|
+
|
|
|
+ LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "InfluxDBPublish - Key: " + _key + ", Content: " + _content + ", Timestamp: " + _timestamp);
|
|
|
|
|
|
if (_timestamp.length() > 0)
|
|
|
{
|
|
|
@@ -168,19 +168,22 @@ void InfluxDBPublish(std::string _key, std::string _content, std::string _timest
|
|
|
strptime(_timestamp.c_str(), PREVALUE_TIME_FORMAT_OUTPUT, &tm);
|
|
|
time_t t = mktime(&tm); // Time in Localtime (looks like timezone is not used by strptime)
|
|
|
|
|
|
- struct tm * ptm;
|
|
|
- ptm = gmtime ( &t );
|
|
|
- time_t utc = mktime(ptm);
|
|
|
- utc = 2*t - utc; // Take care of timezone (looks difficult, but is easy: t = t + (t - utc), weil t-utc = timezone)
|
|
|
+// struct tm * ptm;
|
|
|
+// ptm = gmtime ( &t );
|
|
|
+// time_t utc = mktime(ptm);
|
|
|
|
|
|
- sprintf(nowTimestamp,"%ld000000000", (long) utc); // UTC
|
|
|
+ LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Use handover timestamp: " + _timestamp + " converted GMT timestamp: " + std::to_string(t));
|
|
|
+
|
|
|
+// utc = 2*t - utc; // Take care of timezone (looks difficult, but is easy: t = t + (t - utc), weil t-utc = timezone)
|
|
|
+// LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "time conversion utc after: " + std::to_string(utc));
|
|
|
+
|
|
|
+ sprintf(nowTimestamp,"%ld000000000", (long) t); // UTC
|
|
|
|
|
|
payload = _influxDBMeasurement + " " + _key + "=" + _content + " " + nowTimestamp;
|
|
|
-// payload = _influxDBMeasurement + " " + _key + "=774 " + nowTimestamp;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- payload = _influxDBMeasurement + " " + _key + "=" + _content;
|
|
|
+ payload = _influxDB_V2_Measurement + " " + _key + "=" + _content;
|
|
|
}
|
|
|
|
|
|
payload.shrink_to_fit();
|