compile with esp mqtt lib
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "MqttClient.h"
|
||||
#include "MqttClientSetup.h"
|
||||
|
||||
enum class ReconnectStatus
|
||||
{
|
||||
@@ -16,7 +17,7 @@ public:
|
||||
: _hostname(hostname)
|
||||
{}
|
||||
|
||||
virtual MqttClient* mqttClient() = 0;
|
||||
virtual MqttClientSetup* mqttClient() = 0;
|
||||
|
||||
virtual void initialize() = 0;
|
||||
virtual ReconnectStatus reconnect() = 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ void W5500Device::initialize()
|
||||
|
||||
Ethernet.init(ETHERNET_CS_PIN);
|
||||
_ethClient = new EthernetClient();
|
||||
_mqttClient = new MqttClient(*_ethClient);
|
||||
_mqttClient = new espMqttClientEthernet(_ethClient);
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_log_enabled))
|
||||
{
|
||||
@@ -142,10 +142,6 @@ void W5500Device::printError()
|
||||
Log->println(ESP.getFreeHeap());
|
||||
}
|
||||
|
||||
MqttClient *W5500Device::mqttClient()
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
|
||||
bool W5500Device::isConnected()
|
||||
{
|
||||
@@ -188,3 +184,9 @@ int8_t W5500Device::signalStrength()
|
||||
{
|
||||
return 127;
|
||||
}
|
||||
|
||||
MqttClientSetup *W5500Device::mqttClient()
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "NetworkDevice.h"
|
||||
#include "espMqttClient.h"
|
||||
#include <Ethernet.h>
|
||||
#include <Preferences.h>
|
||||
|
||||
@@ -21,14 +22,14 @@ public:
|
||||
|
||||
int8_t signalStrength() override;
|
||||
|
||||
virtual MqttClient *mqttClient();
|
||||
virtual MqttClientSetup* mqttClient();
|
||||
|
||||
private:
|
||||
void resetDevice();
|
||||
void initializeMacAddress(byte* mac);
|
||||
|
||||
EthernetClient* _ethClient = nullptr;
|
||||
MqttClient* _mqttClient = nullptr;
|
||||
MqttClientSetup* _mqttClient = nullptr;
|
||||
Preferences* _preferences = nullptr;
|
||||
|
||||
int _maintainResult = 0;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../PreferencesKeys.h"
|
||||
#include "../Logger.h"
|
||||
#include "../MqttTopics.h"
|
||||
#include "espMqttClient.h"
|
||||
|
||||
RTC_NOINIT_ATTR char WiFiDevice_reconfdetect[17];
|
||||
|
||||
@@ -31,12 +32,13 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
|
||||
_wifiClientSecure->setCertificate(_cert);
|
||||
_wifiClientSecure->setPrivateKey(_key);
|
||||
}
|
||||
_mqttClient = new MqttClient(*_wifiClientSecure);
|
||||
// TODO
|
||||
// _mqttClient = new espMqttClient(*_wifiClientSecure);
|
||||
} else
|
||||
{
|
||||
Log->println(F("MQTT without TLS."));
|
||||
_wifiClient = new WiFiClient();
|
||||
_mqttClient = new MqttClient(*_wifiClient);
|
||||
_mqttClient = new espMqttClient(_wifiClient);
|
||||
}
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_log_enabled))
|
||||
@@ -51,11 +53,6 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
|
||||
}
|
||||
}
|
||||
|
||||
MqttClient *WifiDevice::mqttClient()
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
|
||||
void WifiDevice::initialize()
|
||||
{
|
||||
std::vector<const char *> wm_menu;
|
||||
@@ -152,3 +149,8 @@ void WifiDevice::clearRtcInitVar(WiFiManager *)
|
||||
{
|
||||
memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect);
|
||||
}
|
||||
|
||||
MqttClientSetup *WifiDevice::mqttClient()
|
||||
{
|
||||
return _mqttClient;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
int8_t signalStrength() override;
|
||||
|
||||
virtual MqttClient* mqttClient();
|
||||
MqttClientSetup *mqttClient() override;
|
||||
|
||||
private:
|
||||
static void clearRtcInitVar(WiFiManager*);
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
WiFiManager _wm;
|
||||
WiFiClient* _wifiClient = nullptr;
|
||||
WiFiClientSecure* _wifiClientSecure = nullptr;
|
||||
MqttClient* _mqttClient = nullptr;
|
||||
MqttClientSetup* _mqttClient = nullptr;
|
||||
// SpiffsCookie _cookie;
|
||||
bool _restartOnDisconnect = false;
|
||||
bool _startAp = false;
|
||||
|
||||
Reference in New Issue
Block a user