|
|
|
@ -176,26 +176,35 @@ void pushToInfluxDB(String device, float sensorValues[]) {
|
|
|
|
|
void _writePoint()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
uint32_t _timeout = millis();
|
|
|
|
|
|
|
|
|
|
debug("InfluxDB: check connection");
|
|
|
|
|
do {
|
|
|
|
|
} while (client.validateConnection() and (_timeout + INFLUXDB_TIMEOUT_MS) <= millis());
|
|
|
|
|
|
|
|
|
|
if (! client.validateConnection())
|
|
|
|
|
{
|
|
|
|
|
debug("Can't write to InfluxDB2, timeout validating connection");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_timeout = millis();
|
|
|
|
|
|
|
|
|
|
debug("InfluxDB: waiting for write ready");
|
|
|
|
|
// wait unitl ready
|
|
|
|
|
do {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
Serial.print("InfluxDB: waiting for write ready\n");
|
|
|
|
|
#endif
|
|
|
|
|
} while (client.canSendRequest() == false);
|
|
|
|
|
} while (client.canSendRequest() == false and (_timeout + INFLUXDB_TIMEOUT_MS) <= millis());
|
|
|
|
|
|
|
|
|
|
if (! client.canSendRequest())
|
|
|
|
|
{
|
|
|
|
|
debug("Can't write to InfluxDB2, timeout canSendRequest");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Write point
|
|
|
|
|
if (!client.writePoint(sensor)) {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
Serial.print("InfluxDB write failed: ");
|
|
|
|
|
Serial.println(client.getLastErrorMessage());
|
|
|
|
|
Serial.print("\nErrorcode: ");
|
|
|
|
|
Serial.println(client.getLastStatusCode());
|
|
|
|
|
Serial.print("\n");
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
Serial.print("InfluxDB write done\n");
|
|
|
|
|
#endif
|
|
|
|
|
if (!client.writePoint(sensor))
|
|
|
|
|
{
|
|
|
|
|
debug("InfluxDB write failed: " + String(client.getLastErrorMessage()) + " Err: " + String(client.getLastStatusCode()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|