remove NetworkDevice dependency from MqttLogger library
This commit is contained in:
@@ -57,7 +57,7 @@ EthLan8720Device::EthLan8720Device(const String& hostname, Preferences* preferen
|
||||
String pathStr = preferences->getString(preference_mqtt_lock_path);
|
||||
pathStr.concat(mqtt_topic_log);
|
||||
strcpy(_path, pathStr.c_str());
|
||||
Log = new MqttLogger(this, _path, MqttLoggerMode::MqttAndSerial);
|
||||
Log = new MqttLogger(*getMqttClient(), _path, MqttLoggerMode::MqttAndSerial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,3 +342,14 @@ void EthLan8720Device::disableMqtt()
|
||||
_mqttEnabled = false;
|
||||
}
|
||||
|
||||
MqttClient *EthLan8720Device::getMqttClient() const
|
||||
{
|
||||
if (_useEncryption)
|
||||
{
|
||||
return _mqttClientSecure;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
|
||||
private:
|
||||
void onDisconnected();
|
||||
MqttClient *getMqttClient() const;
|
||||
|
||||
espMqttClient* _mqttClient = nullptr;
|
||||
espMqttClientSecure* _mqttClientSecure = nullptr;
|
||||
|
||||
@@ -61,7 +61,7 @@ void W5500Device::initialize()
|
||||
_path = new char[pathStr.length() + 1];
|
||||
memset(_path, 0, sizeof(_path));
|
||||
strcpy(_path, pathStr.c_str());
|
||||
Log = new MqttLogger(this, _path, MqttLoggerMode::MqttAndSerial);
|
||||
Log = new MqttLogger(_mqttClient, _path, MqttLoggerMode::MqttAndSerial);
|
||||
}
|
||||
|
||||
reconnect();
|
||||
|
||||
@@ -51,7 +51,7 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* preferences, const I
|
||||
String pathStr = preferences->getString(preference_mqtt_lock_path);
|
||||
pathStr.concat(mqtt_topic_log);
|
||||
strcpy(_path, pathStr.c_str());
|
||||
Log = new MqttLogger(this, _path, MqttLoggerMode::MqttAndSerial);
|
||||
Log = new MqttLogger(*getMqttClient(), _path, MqttLoggerMode::MqttAndSerial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,3 +367,15 @@ void WifiDevice::disableMqtt()
|
||||
|
||||
_mqttEnabled = false;
|
||||
}
|
||||
|
||||
MqttClient *WifiDevice::getMqttClient() const
|
||||
{
|
||||
if (_useEncryption)
|
||||
{
|
||||
return _mqttClientSecure;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ private:
|
||||
static void clearRtcInitVar(WiFiManager*);
|
||||
|
||||
void onDisconnected();
|
||||
MqttClient *getMqttClient() const;
|
||||
|
||||
WiFiManager _wm;
|
||||
espMqttClient* _mqttClient = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user