forked from tobiasschuerg/InfluxDB-Client-for-Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfluxData.h
39 lines (32 loc) · 990 Bytes
/
InfluxData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
ESP8266 InfluxDb: InfluxData
Purpose: Holds the data of a single measurement.
@see
https://docs.influxdata.com/influxdb/v1.5/concepts/glossary/#measurement
@author Tobias Schürg
*/
class InfluxData {
public:
InfluxData(String measurement) : _measurement(measurement) {}
void addTag(String key, String value) { _tags += "," + key + "=" + value; }
void addValue(String key, float value) {
_values = (_values == "") ? (" ") : (_values += ",");
_values += key + "=" + String(value);
}
void addValueString(String key, String value) {
_values = (_values == "") ? (" ") : (_values += ",");
_values += key + "=\"" + value + "\"";
}
void setTimestamp(long int seconds)
{
_timestamp = " " + String(seconds) + "000000000";
}
String toString() const { return _measurement + _tags + _values + _timestamp; }
private:
String _measurement;
String _tags;
String _values;
String _timestamp;
String _bucket;
String _org;
};