From 8b0ff9bb46730f36033a26a043488cef42f7ac5b Mon Sep 17 00:00:00 2001 From: Markus Rudel Date: Sat, 14 Jul 2018 19:15:38 +0200 Subject: [PATCH] added empty constructor so that the class can be initialized after the configuration details are known --- ESPinfluxdb.cpp | 15 +++++++++++++++ ESPinfluxdb.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/ESPinfluxdb.cpp b/ESPinfluxdb.cpp index e781ae3..d51284e 100644 --- a/ESPinfluxdb.cpp +++ b/ESPinfluxdb.cpp @@ -11,11 +11,26 @@ #define _DEBUG #endif +Influxdb::Influxdb() +{ + // empty constructor so that host and port can be initialized later +} + Influxdb::Influxdb(const char *host, uint16_t port) { _port = String(port); _host = String(host); } +void Influxdb::setHost(const char *host) +{ + _host = String(host); +} + +void Influxdb::setPort(uint16_t port) +{ + _port = String(port); +} + DB_RESPONSE Influxdb::opendb(String db, String user, String password) { _db = db + "&u=" + user + "&p=" + password; } diff --git a/ESPinfluxdb.h b/ESPinfluxdb.h index cd056e7..dd4040f 100644 --- a/ESPinfluxdb.h +++ b/ESPinfluxdb.h @@ -40,8 +40,12 @@ String _tag; class Influxdb { public: +Influxdb(); Influxdb(const char* host, uint16_t port); +void setHost(const char* host); +void setPort(uint16_t port); + DB_RESPONSE opendb(String db); DB_RESPONSE opendb(String db, String user, String password); DB_RESPONSE write(dbMeasurement data);