forked from domints/ESP-Ruuvi-Collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfluxArduino.hpp
69 lines (56 loc) · 2.15 KB
/
InfluxArduino.hpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef InfluxArduino_hpp
#define InfluxArduino_hpp
class InfluxArduino
{
public:
InfluxArduino();
~InfluxArduino();
//specify the database, IP address and port (optional) for the database
void configure(const char database[], const char host[], const uint16_t port = 8086);
//if you require authorization to write to InfluxDB, set the username and password here
void authorize(const char username[],const char password[]);
//if you are using HTTPS, specify your CA certificate:
void addCertificate(const char ROOT_CERT[]);
/*
* write tags and fields to the measurement. These will likely be made by sprintf,
* or the Arduino String class (which I don't particularly like, but each to their own)
* The example .ino file might be useful to see.
* for both tags and fields, the format is <key=value>.
* If you have multiple values, separate each pair with a comma,
* but do not put any spaces in anywhere.
* example:
* tags: "tag_1=A,another_tag=bee"
* fields: "x=0.9823401,y=-0.1"
*/
bool write(const char *measurement, const char *tagString, const char *fieldString);
//tags are optional: you can just specify a measurement plus fields
bool write(const char *measurement, const char *fieldString);
/*
* return the HTTPClient response
* if POST is unsuccessful a negative number is returned:
* you can find what this means in the HTTPClient.h header file.
* Otherwise, it returns an HTTP code, e.g. 204 or 403)
*/
int getResponse();
//a bool to check if https is being used.
bool isSecure();
/*
* TODO: method ping() to test configuration values.
* curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
*/
/*
* TODO: method to create a database.
* curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
*/
private:
char* _database;
char* _host;
uint16_t _port;
char* _username;
char* _password;
char* _cert;
bool _isAuthorised = false;
bool _isSecure = false;
int _latestResponse; //storing the latest response in case user wants to inspect
};
#endif