mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[AutoDiscovery] Make start delay compiletime configurable, and extend max delay from 10 to 30 sec.
This commit is contained in:
+3
-3
@@ -90,7 +90,7 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String&
|
||||
// (ControllerSettings->MqttAutoDiscoveryTrigger[0] != 0) &&
|
||||
(ControllerSettings->MqttAutoDiscoveryTopic[0] != 0)) {
|
||||
mqttDiscoveryController = event->ControllerIndex;
|
||||
mqttDiscoveryTimeout = random(10, 100);
|
||||
mqttDiscoveryTimeout = random(10, MQTT_DISCOVERY_MAX_DELAY_0_1_SECONDS);
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, strformat(F("C005 : INIT: AutoDiscovery for Controller %d in %.1f sec."),
|
||||
@@ -155,8 +155,8 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String&
|
||||
&& event->String2.equals(online.isEmpty() ? F("online") : online)
|
||||
) {
|
||||
// We have received the Discovery request topic
|
||||
// Generate random time-offset in 0.1 sec, range 1..10 seconds
|
||||
mqttDiscoveryTimeout = random(10, 100);
|
||||
// Generate random time-offset in 0.1 sec, range 1..30 seconds
|
||||
mqttDiscoveryTimeout = random(10, MQTT_DISCOVERY_MAX_DELAY_0_1_SECONDS);
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, strformat(F("C005 : Request for AutoDiscovery received. %.1f sec."),
|
||||
|
||||
@@ -35,7 +35,6 @@ controllerIndex_t mqttDiscoveryController = INVALID_CONTROLLER_INDEX;
|
||||
taskIndex_t mqttDiscoverOnlyTask = INVALID_TASK_INDEX;
|
||||
uint32_t mqttDiscoveryTimeout = 0; // Decremented in 10 per second, random timeout before discovery is sent, for broker load
|
||||
// distribution
|
||||
// uint32_t mqttDiscoveryLastRun = 0; // FIXME Leave a minimum time between discoveries?
|
||||
# endif // if FEATURE_MQTT_DISCOVER
|
||||
#endif // if FEATURE_MQTT
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# include <PubSubClient.h>
|
||||
|
||||
# if FEATURE_MQTT_TLS
|
||||
#include <WiFiClientSecureLightBearSSL.h>
|
||||
# include <WiFiClientSecureLightBearSSL.h>
|
||||
# endif // if FEATURE_MQTT_TLS
|
||||
|
||||
// MQTT client
|
||||
@@ -22,8 +22,9 @@ extern WiFiClient mqtt;
|
||||
# if FEATURE_MQTT_TLS
|
||||
extern String mqtt_tls_last_errorstr;
|
||||
extern int32_t mqtt_tls_last_error;
|
||||
extern BearSSL::WiFiClientSecure_light* mqtt_tls;
|
||||
//extern BearSSL::X509List mqtt_X509List;
|
||||
extern BearSSL::WiFiClientSecure_light*mqtt_tls;
|
||||
|
||||
// extern BearSSL::X509List mqtt_X509List;
|
||||
|
||||
extern String mqtt_rootCA;
|
||||
extern String mqtt_fingerprint;
|
||||
@@ -46,7 +47,8 @@ extern bool P037_MQTTImport_connected;
|
||||
#if FEATURE_MQTT_DISCOVER
|
||||
extern controllerIndex_t mqttDiscoveryController;
|
||||
extern taskIndex_t mqttDiscoverOnlyTask;
|
||||
extern uint32_t mqttDiscoveryTimeout;
|
||||
extern uint32_t mqttDiscoveryTimeout;
|
||||
# define MQTT_DISCOVERY_MAX_DELAY_0_1_SECONDS 300 // 300 x 0.1 sec. max random delay before starting Auto Discovery, minimum fixed at 1 sec
|
||||
#endif // if FEATURE_MQTT_DISCOVER
|
||||
|
||||
#endif // GLOBALS_MQTT_H
|
||||
|
||||
@@ -102,8 +102,8 @@ void handle_controllers() {
|
||||
// && (ControllerSettings->MqttAutoDiscoveryTrigger[0] != 0)
|
||||
&& (ControllerSettings->MqttAutoDiscoveryTopic[0] != 0)
|
||||
) {
|
||||
// Generate random time-offset in 0.1 sec, range 1..10 seconds
|
||||
mqttDiscoveryTimeout = random(10, 100);
|
||||
// Generate random time-offset in 0.1 sec, range 1..30 seconds
|
||||
mqttDiscoveryTimeout = random(10, MQTT_DISCOVERY_MAX_DELAY_0_1_SECONDS);
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, strformat(F("MQTT : Start AutoDiscovery on Save. Starting in %.1f sec."), mqttDiscoveryTimeout / 10));
|
||||
|
||||
@@ -486,7 +486,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task
|
||||
|
||||
if (validControllerIndex(discoverController) && validControllerIndex(mqttDiscoveryController)) {
|
||||
mqttDiscoverOnlyTask = taskIndex;
|
||||
mqttDiscoveryTimeout = random(10, 100);
|
||||
mqttDiscoveryTimeout = random(10, MQTT_DISCOVERY_MAX_DELAY_0_1_SECONDS);
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, strformat(F("MQTT : Resend AutoDiscovery for Task %d on Controller %d in %.1f sec."),
|
||||
|
||||
Reference in New Issue
Block a user