make mqtt logging configurable
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define preference_mqtt_broker_port "mqttport"
|
||||
#define preference_mqtt_user "mqttuser"
|
||||
#define preference_mqtt_password "mqttpass"
|
||||
#define preference_mqtt_log_enabled "mqttlog"
|
||||
#define preference_lock_enabled "lockena"
|
||||
#define preference_mqtt_lock_path "mqttpath"
|
||||
#define preference_opener_enabled "openerena"
|
||||
|
||||
@@ -277,6 +277,11 @@ bool WebCfgServer::processArgs(String& message)
|
||||
_preferences->putInt(preference_restart_timer, value.toInt());
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "MQTTLOG")
|
||||
{
|
||||
_preferences->putBool(preference_mqtt_log_enabled, (value == "1"));
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "LSTINT")
|
||||
{
|
||||
_preferences->putInt(preference_query_interval_lockstate, value.toInt());
|
||||
@@ -586,6 +591,7 @@ void WebCfgServer::buildMqttConfigHtml(String &response)
|
||||
printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5);
|
||||
printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect));
|
||||
printInputField(response, "RSTTMR", "Restart timer (minutes; -1 to disable)", _preferences->getInt(preference_restart_timer), 10);
|
||||
printCheckBox(response, "MQTTLOG", "Enable MQTT logging", _preferences->getBool(preference_mqtt_log_enabled));
|
||||
response.concat("</table>");
|
||||
response.concat("* If no encryption is configured for the MQTT broker, leave empty. Only supported for WiFi connections.<br>");
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ void W5500Device::initialize()
|
||||
_mqttClient = new PubSubClient(*_ethClient);
|
||||
_mqttClient->setBufferSize(_mqttMaxBufferSize);
|
||||
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
_path = new char[200];
|
||||
memset(_path, 0, sizeof(_path));
|
||||
|
||||
@@ -49,6 +52,7 @@ void W5500Device::initialize()
|
||||
pathStr.concat(mqtt_topic_log);
|
||||
strcpy(_path, pathStr.c_str());
|
||||
Log = new MqttLogger(*_mqttClient, _path);
|
||||
}
|
||||
|
||||
reconnect();
|
||||
}
|
||||
|
||||
@@ -41,11 +41,17 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
|
||||
_mqttClient = new PubSubClient(*_wifiClient);
|
||||
}
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
_path = new char[200];
|
||||
memset(_path, 0, sizeof(_path));
|
||||
|
||||
String pathStr = _preferences->getString(preference_mqtt_lock_path);
|
||||
pathStr.concat(mqtt_topic_log);
|
||||
strcpy(_path, pathStr.c_str());
|
||||
Log = new MqttLogger(*_mqttClient, _path);
|
||||
}
|
||||
}
|
||||
|
||||
PubSubClient *WifiDevice::mqttClient()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user