refactor NetworkDevice interface to work with new esp mqtt lib

This commit is contained in:
technyon
2023-01-28 17:17:46 +01:00
parent a6010a7f49
commit 5853b0dc0e
24 changed files with 493 additions and 287 deletions

View File

@@ -2,6 +2,7 @@
#include "NetworkDevice.h"
#include "espMqttClient.h"
#include "espMqttClientEthernet.h"
#include <Ethernet.h>
#include <Preferences.h>
@@ -22,14 +23,31 @@ public:
int8_t signalStrength() override;
virtual MqttClientSetup* mqttClient();
void mqttSetClientId(const char *clientId) override;
void mqttSetCleanSession(bool cleanSession) override;
uint16_t mqttPublish(const char *topic, uint8_t qos, bool retain, const char *payload) override;
uint16_t mqttPublish(const char *topic, uint8_t qos, bool retain, const uint8_t *payload, size_t length) override;
bool mqttConnected() const override;
void mqttSetServer(const char *host, uint16_t port) override;
bool mqttConnect() override;
void mqttSetCredentials(const char *username, const char *password) override;
void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) override;
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
private:
void resetDevice();
void initializeMacAddress(byte* mac);
EthernetClient* _ethClient = nullptr;
MqttClientSetup* _mqttClient = nullptr;
espMqttClientEthernet _mqttClient;
Preferences* _preferences = nullptr;
int _maintainResult = 0;