Skip to content

Commit 5fdd37a

Browse files
committed
InfluxDB authentication support added.
1 parent 9f76290 commit 5fdd37a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

InfluxDb.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ void Influxdb::setDb(String db) {
2929
http.addHeader("Content-Type", "text/plain");
3030
}
3131

32-
// TODO: set db with user & password
33-
32+
/**
33+
* Set the database to be used with authentication.
34+
*/
35+
void Influxdb::setDbAuth(String db, String user, String pass) {
36+
_db = String(db);
37+
_user = user;
38+
_pass = pass;
39+
// TODO: recreate client on db change
40+
// http = new HTTPClient();
41+
http.begin(_host, _port, "/write?u=" + _user + "&p=" + _pass + "&db=" + _db );
42+
http.addHeader("Content-Type", "text/plain");
43+
}
3444
/**
3545
* Prepare a measurement to be sent.
3646
*/

0 commit comments

Comments
 (0)