mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 18:26:30 +00:00
Fix ESP32 InfluxDb initial connection delays
Fix ESP32 InfluxDb initial connection delays using HTTPClient (#18015)
This commit is contained in:
parent
ae518424bc
commit
22abc8ad99
@ -9,15 +9,19 @@ All notable changes to this project will be documented in this file.
|
||||
- Command ``WifiPower 1`` to restore default wifi power
|
||||
- HASPmota `meta` attribute and improved `berry_run`
|
||||
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
### Changed
|
||||
- InfluxDb resolves DNS name before request (#18015)
|
||||
- Shutter sliders in WEBGUI automatically appear and disappear during configuration and update during movement (#18701)
|
||||
|
||||
### Fixed
|
||||
- ESP32 InfluxDb initial connection delays using HTTPClient (#18015)
|
||||
- Shutter bootloop using more than 4 shutters (#18673)
|
||||
- AIThinker webcam issues (#18652)
|
||||
- Berry `tasmota.wifi()` would wrongly report wifi as up
|
||||
- Inverted shutter now reflect status also in WEBGUI and several minor fixes to make "inverted" consistant (#18701)
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -138,13 +138,16 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
||||
- InfluxDb resolves DNS name before request [#18015](https://github.com/arendst/Tasmota/issues/18015)
|
||||
- Refactored Zero Cross Dimmer [#18481](https://github.com/arendst/Tasmota/issues/18481)
|
||||
- Energy power delta report delayed by two seconds allowing hardware to stabilize [#17751](https://github.com/arendst/Tasmota/issues/17751)
|
||||
- Shutter sliders in WEBGUI automatically appear and disappear during configuration and update during movement [#18701](https://github.com/arendst/Tasmota/issues/18701)
|
||||
|
||||
### Fixed
|
||||
- ESP8266 Energy Export Active no update regression from v12.3.1.3
|
||||
- ESP32 InfluxDb initial connection delays using HTTPClient [#18015](https://github.com/arendst/Tasmota/issues/18015)
|
||||
- NovaSDS GUI values [#18444](https://github.com/arendst/Tasmota/issues/18444)
|
||||
- LED PWM ac_dimmer curve was wrongly applied instead of Gamma regression from v12.2.0.5 [#18666](https://github.com/arendst/Tasmota/issues/18666)
|
||||
- Berry rules for string comparisons [#18464](https://github.com/arendst/Tasmota/issues/18464)
|
||||
- Berry a rare condition when a GC causes a memory corruption
|
||||
- AIThinker webcam issues [#18652](https://github.com/arendst/Tasmota/issues/18652)
|
||||
- Shutter bootloop using more than 4 shutters [#18673](https://github.com/arendst/Tasmota/issues/18673)
|
||||
- Partition_Manager.tapp
|
||||
- Inverted shutter now reflect status also in WEBGUI and several minor fixes to make "inverted" consistant [#18701](https://github.com/arendst/Tasmota/issues/18701)
|
||||
- Berry rules for string comparisons [#18464](https://github.com/arendst/Tasmota/issues/18464)
|
||||
- Berry a rare condition when a GC causes a memory corruption
|
||||
- ESP32 Partition_Manager.tapp
|
||||
|
@ -76,17 +76,18 @@
|
||||
#ifndef INFLUXDB_RP
|
||||
#define INFLUXDB_RP "" // [IfxRP] Influxdb v1 retention policy (blank is default, usually autogen infinite)
|
||||
#endif
|
||||
#ifndef INFLUXDB_CONNECT_TIMEOUT
|
||||
#define INFLUXDB_CONNECT_TIMEOUT 2000 // Default timeout in milliseconds
|
||||
#endif
|
||||
|
||||
static const char UninitializedMessage[] PROGMEM = "Unconfigured instance";
|
||||
// This cannot be put to PROGMEM due to the way how it is used
|
||||
static const char RetryAfter[] = "Retry-After";
|
||||
static const char TransferEncoding[] = "Transfer-Encoding";
|
||||
|
||||
WiFiClient *IFDBwifiClient = nullptr;
|
||||
HTTPClient *IFDBhttpClient = nullptr;
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
HTTPClientLight *IFDBhttpClient = nullptr;
|
||||
#else
|
||||
WiFiClient *IFDBwifiClient = nullptr;
|
||||
HTTPClient *IFDBhttpClient = nullptr;
|
||||
#endif
|
||||
|
||||
struct {
|
||||
String _serverUrl; // Connection info
|
||||
@ -159,14 +160,17 @@ bool InfluxDbParameterInit(void) {
|
||||
}
|
||||
|
||||
bool InfluxDbInit(void) {
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (!IFDBhttpClient) {
|
||||
IFDBhttpClient = new HTTPClientLight;
|
||||
}
|
||||
#else
|
||||
IFDBwifiClient = new WiFiClient;
|
||||
if (!IFDBhttpClient) {
|
||||
IFDBhttpClient = new HTTPClient;
|
||||
}
|
||||
#endif
|
||||
IFDBhttpClient->setReuse(IFDB._connectionReuse);
|
||||
#ifdef ESP32
|
||||
IFDBhttpClient->setConnectTimeout(INFLUXDB_CONNECT_TIMEOUT);
|
||||
#endif // ESP32
|
||||
char server[32];
|
||||
snprintf_P(server, sizeof(server), PSTR("Tasmota/%s (%s)"), TasmotaGlobal.version, GetDeviceHardware().c_str());
|
||||
IFDBhttpClient->setUserAgent(server);
|
||||
@ -209,7 +213,11 @@ void InfluxDbAfterRequest(int expectedStatusCode, bool modifyLastConnStatus) {
|
||||
}
|
||||
|
||||
bool InfluxDbValidateConnection(void) {
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (!InfluxDbInit()) {
|
||||
#else
|
||||
if (!IFDBwifiClient && !InfluxDbInit()) {
|
||||
#endif
|
||||
IFDB._lastStatusCode = 0;
|
||||
IFDB._lastErrorResponse = FPSTR(UninitializedMessage);
|
||||
return false;
|
||||
@ -223,7 +231,11 @@ bool InfluxDbValidateConnection(void) {
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("IFX: Validating connection to %s"), url.c_str());
|
||||
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (!IFDBhttpClient->begin(url)) {
|
||||
#else // HTTP only
|
||||
if (!IFDBhttpClient->begin(*IFDBwifiClient, url)) {
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Begin failed"));
|
||||
return false;
|
||||
}
|
||||
@ -238,13 +250,21 @@ bool InfluxDbValidateConnection(void) {
|
||||
}
|
||||
|
||||
int InfluxDbPostData(const char *data) {
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (!InfluxDbInit()) {
|
||||
#else
|
||||
if (!IFDBwifiClient && !InfluxDbInit()) {
|
||||
#endif
|
||||
IFDB._lastStatusCode = 0;
|
||||
IFDB._lastErrorResponse = FPSTR(UninitializedMessage);
|
||||
return 0;
|
||||
}
|
||||
if (data) {
|
||||
#if defined(ESP32) && defined(USE_WEBCLIENT_HTTPS)
|
||||
if (!IFDBhttpClient->begin(IFDB._writeUrl)) {
|
||||
#else
|
||||
if (!IFDBhttpClient->begin(*IFDBwifiClient, IFDB._writeUrl)) {
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: Begin failed"));
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user