Merge branch 'master' into publish-additional-states

This commit is contained in:
iranl
2024-02-17 21:30:44 +01:00
committed by GitHub
23 changed files with 362 additions and 703 deletions

View File

@@ -19,7 +19,7 @@ jobs:
cd ~/arduino*
./install.sh
./arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs
./arduino --install-boards esp32:esp32
./arduino --install-boards esp32:esp32:2.0.9
- name: Install Arduino CMake Toolchain
uses: actions/checkout@v2
with:

View File

@@ -50,6 +50,7 @@ set(SRCFILES
NetworkLock.cpp
NetworkOpener.cpp
networkDevices/NetworkDevice.h
networkDevices/NetworkDevice.cpp
networkDevices/WifiDevice.cpp
networkDevices/W5500Device.cpp
networkDevices/EthLan8720Device.cpp

View File

@@ -11,6 +11,7 @@
#define mqtt_topic_lock_state "/lock/state"
#define mqtt_topic_lock_ha_state "/lock/hastate"
#define mqtt_topic_lock_json "/lock/json"
#define mqtt_topic_query_config "/lock/query/config"
#define mqtt_topic_query_lockstate "/lock/query/lockstate"
#define mqtt_topic_query_keypad "/lock/query/keypad"
@@ -53,6 +54,7 @@
#define mqtt_topic_keypad_command_code "/keypad/command/code"
#define mqtt_topic_keypad_command_enabled "/keypad/command/enabled"
#define mqtt_topic_keypad_command_result "/keypad/command/commandResult"
#define mqtt_topic_keypad_json "/keypad/json"
#define mqtt_topic_presence "/presence/devices"

View File

@@ -357,13 +357,13 @@ bool Network::update()
}
_lastMaintenanceTs = ts;
}
if(_preferences->getBool(preference_check_updates))
{
if(_lastUpdateCheckTs == 0 || (ts - _lastUpdateCheckTs) > 86400000)
{
_lastUpdateCheckTs = ts;
https.useHTTP10(true);
https.begin(GITHUB_LATEST_RELEASE_API_URL);
@@ -373,16 +373,16 @@ bool Network::update()
DynamicJsonDocument doc(6144);
DeserializationError jsonError = deserializeJson(doc, https.getStream());
if (!jsonError) {
if (!jsonError) {
_latestVersion = doc["tag_name"];
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion);
}
}
}
https.end();
}
}
for(const auto& gpioTs : _gpioTs)
{
uint8_t pin = gpioTs.first;
@@ -750,7 +750,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
json["dev"]["mf"] = "Nuki";
json["dev"]["mdl"] = deviceType;
json["dev"]["name"] = name;
String cuUrl = _preferences->getString(preference_mqtt_hass_cu_url);
if (cuUrl != "")
@@ -761,7 +761,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
{
json["dev"]["cu"] = "http://" + _device->localIP();
}
json["~"] = baseTopic;
json["name"] = nullptr;
json["unique_id"] = String(uidString) + "_lock";
@@ -948,11 +948,11 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
"",
{ { "enabled_by_default", "true" },
{"ic", "mdi:counter"}});
if(_preferences->getBool(preference_check_updates))
{
// NUKI Hub latest
publishHassTopic("sensor",
publishHassTopic("sensor",
"nuki_hub_latest",
uidString,
"_nuki_hub_latest",
@@ -967,13 +967,13 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
"",
{ { "enabled_by_default", "true" },
{"ic", "mdi:counter"}});
// NUKI Hub update
char latest_version_topic[250];
_lockPath.toCharArray(latest_version_topic,_lockPath.length() + 1);
strcat(latest_version_topic, mqtt_topic_info_nuki_hub_latest);
publishHassTopic("update",
publishHassTopic("update",
"nuki_hub_update",
uidString,
"_nuki_hub_update",
@@ -989,7 +989,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
{ { "enabled_by_default", "true" },
{ "entity_picture", "https://raw.githubusercontent.com/technyon/nuki_hub/master/icon/favicon-32x32.png" },
{ "release_url", GITHUB_LATEST_RELEASE_URL },
{ "latest_version_topic", latest_version_topic }});
{ "latest_version_topic", latest_version_topic }});
}
else
{
@@ -1053,7 +1053,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
{ "pl_off", "0" },
{ "state_on", "1" },
{ "state_off", "0" }});
// Unlatch
publishHassTopic("button",
"unlatch",
@@ -1069,8 +1069,8 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
"",
String("~") + mqtt_topic_lock_action,
{ { "enabled_by_default", "false" },
{ "pl_prs", "unlatch" }});
{ "pl_prs", "unlatch" }});
}
}
@@ -1386,7 +1386,7 @@ String Network::createHassTopicPath(const String& mqttDeviceType, const String&
path.concat("/");
path.concat(mqttDeviceName);
path.concat("/config");
return path;
}
@@ -1411,18 +1411,18 @@ void Network::removeHASSConfig(char* uidString)
removeHassTopic("lock", "smartlock", uidString);
removeHassTopic("binary_sensor", "battery_low", uidString);
removeHassTopic("binary_sensor", "keypad_battery_low", uidString);
removeHassTopic("sensor", "battery_voltage", uidString);
removeHassTopic("sensor", "battery_voltage", uidString);
removeHassTopic("sensor", "trigger", uidString);
removeHassTopic("binary_sensor", "mqtt_connected", uidString);
removeHassTopic("switch", "reset", uidString);
removeHassTopic("switch", "reset", uidString);
removeHassTopic("sensor", "firmware_version", uidString);
removeHassTopic("sensor", "hardware_version", uidString);
removeHassTopic("sensor", "nuki_hub_version", uidString);
removeHassTopic("sensor", "nuki_hub_latest", uidString);
removeHassTopic("update", "nuki_hub_update", uidString);
removeHassTopic("sensor", "nuki_hub_ip", uidString);
removeHassTopic("switch", "led_enabled", uidString);
removeHassTopic("switch", "button_enabled", uidString);
removeHassTopic("switch", "led_enabled", uidString);
removeHassTopic("switch", "button_enabled", uidString);
removeHassTopic("button", "unlatch", uidString);
removeHassTopic("button", "lockngo", uidString);
removeHassTopic("button", "lockngounlatch", uidString);
@@ -1430,7 +1430,7 @@ void Network::removeHASSConfig(char* uidString)
removeHassTopic("binary_sensor", "door_sensor", uidString);
removeHassTopic("binary_sensor", "ring", uidString);
removeHassTopic("number", "led_brightness", uidString);
removeHassTopic("sensor", "sound_level", uidString);
removeHassTopic("sensor", "sound_level", uidString);
removeHassTopic("number", "sound_level", uidString);
removeHassTopic("sensor", "last_action_authorization", uidString);
removeHassTopic("sensor", "keypad_status", uidString);
@@ -1475,17 +1475,17 @@ DynamicJsonDocument Network::createHassJson(const String& uidString,
{
json["dev_cla"] = deviceClass;
}
if(stateTopic != "")
{
json["stat_t"] = stateTopic;
}
if(stateClass != "")
{
json["stat_cla"] = stateClass;
}
if(entityCat != "")
{
json["ent_cat"] = entityCat;
@@ -1495,7 +1495,7 @@ DynamicJsonDocument Network::createHassJson(const String& uidString,
{
json["cmd_t"] = commandTopic;
}
json["avty"]["t"] = _lockPath + mqtt_topic_mqtt_connection_state;
for(const auto& entry : additionalEntries)
@@ -1513,7 +1513,7 @@ DynamicJsonDocument Network::createHassJson(const String& uidString,
json[entry.first] = entry.second;
}
}
return json;
}

View File

@@ -209,11 +209,15 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
void NetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurnerState, const NukiLock::KeyTurnerState& lastKeyTurnerState)
{
char str[50];
memset(&str, 0, sizeof(str));
DynamicJsonDocument json(_bufferSize);
lockstateToString(keyTurnerState.lockState, str);
if((_firstTunerStatePublish || keyTurnerState.lockState != lastKeyTurnerState.lockState) && keyTurnerState.lockState != NukiLock::LockState::Undefined)
{
memset(&str, 0, sizeof(str));
lockstateToString(keyTurnerState.lockState, str);
publishString(mqtt_topic_lock_state, str);
if(_haEnabled)
@@ -222,34 +226,48 @@ void NetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurne
}
}
json["lock_state"] = str;
memset(&str, 0, sizeof(str));
triggerToString(keyTurnerState.trigger, str);
if(_firstTunerStatePublish || keyTurnerState.trigger != lastKeyTurnerState.trigger)
{
memset(&str, 0, sizeof(str));
triggerToString(keyTurnerState.trigger, str);
publishString(mqtt_topic_lock_trigger, str);
}
json["trigger"] = str;
memset(&str, 0, sizeof(str));
lockactionToString(keyTurnerState.lastLockAction, str);
if(_firstTunerStatePublish || keyTurnerState.lastLockAction != lastKeyTurnerState.lastLockAction)
{
memset(&str, 0, sizeof(str));
lockactionToString(keyTurnerState.lastLockAction, str);
publishString(mqtt_topic_lock_last_lock_action, str);
}
json["last_lock_action"] = str;
memset(&str, 0, sizeof(str));
NukiLock::completionStatusToString(keyTurnerState.lastLockActionCompletionStatus, str);
if(_firstTunerStatePublish || keyTurnerState.lastLockActionCompletionStatus != lastKeyTurnerState.lastLockActionCompletionStatus)
{
memset(&str, 0, sizeof(str));
NukiLock::completionStatusToString(keyTurnerState.lastLockActionCompletionStatus, str);
publishString(mqtt_topic_lock_completionStatus, str);
}
json["lock_completion_status"] = str;
memset(&str, 0, sizeof(str));
NukiLock::doorSensorStateToString(keyTurnerState.doorSensorState, str);
if(_firstTunerStatePublish || keyTurnerState.doorSensorState != lastKeyTurnerState.doorSensorState)
{
memset(&str, 0, sizeof(str));
NukiLock::doorSensorStateToString(keyTurnerState.doorSensorState, str);
publishString(mqtt_topic_lock_door_sensor_state, str);
}
json["door_sensor_state"] = str;
if(_firstTunerStatePublish || keyTurnerState.criticalBatteryState != lastKeyTurnerState.criticalBatteryState)
{
bool critical = (keyTurnerState.criticalBatteryState & 0b00000001) > 0;
@@ -273,6 +291,12 @@ void NetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurne
}
}
json["auth_id"] = authId;
json["auth_name"] = authName;
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_lock_json, _buffer);
_firstTunerStatePublish = false;
}
@@ -315,8 +339,6 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
char str[50];
bool authFound = false;
uint32_t authId = 0;
char authName[33];
memset(authName, 0, sizeof(authName));
DynamicJsonDocument json(_bufferSize);
@@ -471,15 +493,35 @@ void NetworkLock::publishBleAddress(const std::string &address)
void NetworkLock::publishKeypad(const std::list<NukiLock::KeypadEntry>& entries, uint maxKeypadCodeCount)
{
uint index = 0;
DynamicJsonDocument json(_bufferSize);
for(const auto& entry : entries)
{
String basePath = mqtt_topic_keypad;
basePath.concat("/code_");
basePath.concat(std::to_string(index).c_str());
publishKeypadEntry(basePath, entry);
auto jsonEntry = json.add();
jsonEntry["id"] = entry.codeId;
jsonEntry["enabled"] = entry.enabled;
jsonEntry["name"] = entry.name;
jsonEntry["createdYear"] = entry.dateCreatedYear;
jsonEntry["createdMonth"] = entry.dateCreatedMonth;
jsonEntry["createdDay"] = entry.dateCreatedDay;
jsonEntry["createdHour"] = entry.dateCreatedHour;
jsonEntry["createdMin"] = entry.dateCreatedMin;
jsonEntry["createdSec"] = entry.dateCreatedSec;
jsonEntry["lockCount"] = entry.lockCount;
++index;
}
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_keypad_json, _buffer);
while(index < maxKeypadCodeCount)
{
NukiLock::KeypadEntry entry;

View File

@@ -73,14 +73,16 @@ private:
bool _firstTunerStatePublish = true;
unsigned long _lastMaintenanceTs = 0;
bool _haEnabled= false;
bool _haEnabled = false;
bool _reconnected = false;
String _keypadCommandName = "";
String _keypadCommandCode = "";
uint _keypadCommandId = 0;
int _keypadCommandEnabled = 1;
uint8_t _queryCommands = 0;
uint8_t _queryCommands = 0;
uint32_t authId = 0;
char authName[33];
char* _buffer;
size_t _bufferSize;

View File

@@ -202,18 +202,20 @@ void NetworkOpener::publishKeyTurnerState(const NukiOpener::OpenerState& keyTurn
_currentLockState = keyTurnerState.lockState;
char str[50];
memset(&str, 0, sizeof(str));
DynamicJsonDocument json(_bufferSize);
lockstateToString(keyTurnerState.lockState, str);
if((_firstTunerStatePublish || keyTurnerState.lockState != lastKeyTurnerState.lockState || keyTurnerState.nukiState != lastKeyTurnerState.nukiState) && keyTurnerState.lockState != NukiOpener::LockState::Undefined)
{
memset(&str, 0, sizeof(str));
if(keyTurnerState.nukiState == NukiOpener::State::ContinuousMode)
{
publishString(mqtt_topic_lock_state, "ContinuousMode");
}
else
{
lockstateToString(keyTurnerState.lockState, str);
publishString(mqtt_topic_lock_state, str);
}
@@ -223,34 +225,57 @@ void NetworkOpener::publishKeyTurnerState(const NukiOpener::OpenerState& keyTurn
}
}
json["lock_state"] = str;
if(keyTurnerState.nukiState == NukiOpener::State::ContinuousMode)
{
json["continuous_mode"] = 1;
} else {
json["continuous_mode"] = 0;
}
memset(&str, 0, sizeof(str));
triggerToString(keyTurnerState.trigger, str);
if(_firstTunerStatePublish || keyTurnerState.trigger != lastKeyTurnerState.trigger)
{
memset(&str, 0, sizeof(str));
triggerToString(keyTurnerState.trigger, str);
publishString(mqtt_topic_lock_trigger, str);
}
json["trigger"] = str;
memset(&str, 0, sizeof(str));
completionStatusToString(keyTurnerState.lastLockActionCompletionStatus, str);
if(_firstTunerStatePublish || keyTurnerState.lastLockActionCompletionStatus != lastKeyTurnerState.lastLockActionCompletionStatus)
{
memset(&str, 0, sizeof(str));
completionStatusToString(keyTurnerState.lastLockActionCompletionStatus, str);
publishString(mqtt_topic_lock_completionStatus, str);
}
json["lock_completion_status"] = str;
memset(&str, 0, sizeof(str));
NukiOpener::doorSensorStateToString(keyTurnerState.doorSensorState, str);
if(_firstTunerStatePublish || keyTurnerState.doorSensorState != lastKeyTurnerState.doorSensorState)
{
memset(&str, 0, sizeof(str));
NukiOpener::doorSensorStateToString(keyTurnerState.doorSensorState, str);
publishString(mqtt_topic_lock_door_sensor_state, str);
}
json["door_sensor_state"] = str;
if(_firstTunerStatePublish || keyTurnerState.criticalBatteryState != lastKeyTurnerState.criticalBatteryState)
{
bool critical = (keyTurnerState.criticalBatteryState & 0b00000001) > 0;
publishBool(mqtt_topic_battery_critical, critical);
}
json["auth_id"] = authId;
json["auth_name"] = authName;
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_lock_json, _buffer);
_firstTunerStatePublish = false;
}
@@ -302,8 +327,6 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
char str[50];
bool authFound = false;
uint32_t authId = 0;
char authName[33];
memset(authName, 0, sizeof(authName));
DynamicJsonDocument json(_bufferSize);
@@ -527,15 +550,35 @@ void NetworkOpener::removeHASSConfig(char* uidString)
void NetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& entries, uint maxKeypadCodeCount)
{
uint index = 0;
DynamicJsonDocument json(_bufferSize);
for(const auto& entry : entries)
{
String basePath = mqtt_topic_keypad;
basePath.concat("/code_");
basePath.concat(std::to_string(index).c_str());
publishKeypadEntry(basePath, entry);
auto jsonEntry = json.add();
jsonEntry["id"] = entry.codeId;
jsonEntry["enabled"] = entry.enabled;
jsonEntry["name"] = entry.name;
jsonEntry["createdYear"] = entry.dateCreatedYear;
jsonEntry["createdMonth"] = entry.dateCreatedMonth;
jsonEntry["createdDay"] = entry.dateCreatedDay;
jsonEntry["createdHour"] = entry.dateCreatedHour;
jsonEntry["createdMin"] = entry.dateCreatedMin;
jsonEntry["createdSec"] = entry.dateCreatedSec;
jsonEntry["lockCount"] = entry.lockCount;
++index;
}
serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_keypad_json, _buffer);
while(index < maxKeypadCodeCount)
{
NukiLock::KeypadEntry entry;

View File

@@ -82,6 +82,9 @@ private:
int _keypadCommandEnabled = 1;
unsigned long _resetLockStateTs = 0;
uint8_t _queryCommands = 0;
uint32_t authId = 0;
char authName[33];
NukiOpener::LockState _currentLockState = NukiOpener::LockState::Undefined;
char* _buffer;

View File

@@ -324,8 +324,14 @@ void NukiWrapper::updateKeyTurnerState()
}
return;
}
_retryLockstateCount = 0;
if(_publishAuthData)
{
updateAuthData();
}
_network->publishKeyTurnerState(_keyTurnerState, _lastKeyTurnerState);
updateGpioOutputs();
@@ -333,11 +339,6 @@ void NukiWrapper::updateKeyTurnerState()
lockstateToString(_keyTurnerState.lockState, lockStateStr);
Log->println(lockStateStr);
if(_publishAuthData)
{
updateAuthData();
}
postponeBleWatchdog();
}

View File

@@ -749,13 +749,13 @@ void WebCfgServer::buildOtaHtml(String &response, bool errored)
if(_preferences->getBool(preference_check_updates))
{
response.concat("<button title=\"Open latest release on GitHub\" onclick=\" window.open('");
response.concat("<div id=\"gitdiv\"><button title=\"Open latest release on GitHub\" onclick=\" window.open('");
response.concat(GITHUB_LATEST_RELEASE_URL);
response.concat("', '_blank'); return false;\">Open latest release on GitHub</button>");
response.concat("<br><br><button title=\"Download latest binary from GitHub\" onclick=\" window.open('");
response.concat(GITHUB_LATEST_RELEASE_BINARY_URL);
response.concat("'); return false;\">Download latest binary from GitHub</button>");
response.concat("'); return false;\">Download latest binary from GitHub</button></div>");
}
response.concat("<div id=\"msgdiv\" style=\"visibility:hidden\">Initiating Over-the-air update. This will take about two minutes, please be patient.<br>You will be forwarded automatically when the update is complete.</div>");
@@ -765,6 +765,7 @@ void WebCfgServer::buildOtaHtml(String &response, bool errored)
response.concat(" button.addEventListener('click',hideshow,false);");
response.concat(" function hideshow() {");
response.concat(" document.getElementById('upform').style.visibility = 'hidden';");
response.concat(" document.getElementById('gitdiv').style.visibility = 'hidden';");
response.concat(" document.getElementById('msgdiv').style.visibility = 'visible';");
response.concat(" }");
response.concat("});");
@@ -1374,4 +1375,4 @@ String WebCfgServer::getPreselectionForGpio(const uint8_t &pin)
}
return String((int8_t)PinRole::Disabled);
}
}

View File

@@ -8,4 +8,4 @@ category=Communication
url=https://github.com/androbi-com/MqttLogger
architectures=*
includes=MqttLogger.h
depends=PubSubClient
depends=espMqttClient

View File

@@ -7,7 +7,7 @@ MqttLogger::MqttLogger(MqttLoggerMode mode)
this->setBufferSize(MQTT_MAX_PACKET_SIZE);
}
MqttLogger::MqttLogger(NetworkDevice* client, const char* topic, MqttLoggerMode mode)
MqttLogger::MqttLogger(MqttClient& client, const char* topic, MqttLoggerMode mode)
{
this->setClient(client);
this->setTopic(topic);
@@ -19,9 +19,9 @@ MqttLogger::~MqttLogger()
{
}
void MqttLogger::setClient(NetworkDevice* client)
void MqttLogger::setClient(MqttClient& client)
{
this->client = client;
this->client = &client;
}
void MqttLogger::setTopic(const char* topic)
@@ -74,9 +74,9 @@ void MqttLogger::sendBuffer()
if (this->bufferCnt > 0)
{
bool doSerial = this->mode==MqttLoggerMode::SerialOnly || this->mode==MqttLoggerMode::MqttAndSerial;
if (this->mode!=MqttLoggerMode::SerialOnly && this->client != NULL && this->client->mqttConnected())
if (this->mode!=MqttLoggerMode::SerialOnly && this->client != NULL && this->client->connected())
{
this->client->mqttPublish(topic, 0, true, (uint8_t*)this->buffer, this->bufferCnt);
this->client->publish(topic, 0, true, this->buffer, this->bufferCnt);
} else if (this->mode == MqttLoggerMode::MqttAndSerialFallback)
{
doSerial = true;

View File

@@ -11,7 +11,7 @@
#include <Arduino.h>
#include <Print.h>
#include "../../../networkDevices/NetworkDevice.h"
#include <espMqttClient.h>
#define MQTT_MAX_PACKET_SIZE 1024
@@ -29,16 +29,16 @@ private:
uint8_t* buffer;
uint8_t* bufferEnd;
uint16_t bufferCnt = 0, bufferSize = 0;
NetworkDevice* client;
MqttClient* client;
MqttLoggerMode mode;
void sendBuffer();
public:
MqttLogger(MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
MqttLogger(NetworkDevice* client, const char* topic, MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
MqttLogger(MqttClient& client, const char* topic, MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
~MqttLogger();
void setClient(NetworkDevice* client);
void setClient(MqttClient& client);
void setTopic(const char* topic);
void setMode(MqttLoggerMode mode);
void setRetained(boolean retained);

View File

@@ -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);
}
}
@@ -96,12 +96,6 @@ void EthLan8720Device::reconfigure()
restartEsp(RestartReason::ReconfigureLAN8720);
}
void EthLan8720Device::printError()
{
Log->print(F("Free Heap: "));
Log->println(ESP.getFreeHeap());
}
bool EthLan8720Device::supportsEncryption()
{
return true;
@@ -132,20 +126,6 @@ ReconnectStatus EthLan8720Device::reconnect()
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
}
void EthLan8720Device::update()
{
if(_mqttEnabled)
{
if (_useEncryption)
{
_mqttClientSecure->loop();
} else
{
_mqttClient->loop();
}
}
}
void EthLan8720Device::onDisconnected()
{
if(millis() > 60000)
@@ -163,187 +143,3 @@ String EthLan8720Device::localIP()
{
return ETH.localIP().toString();
}
void EthLan8720Device::mqttSetClientId(const char *clientId)
{
if(_useEncryption)
{
_mqttClientSecure->setClientId(clientId);
}
else
{
_mqttClient->setClientId(clientId);
}
}
void EthLan8720Device::mqttSetCleanSession(bool cleanSession)
{
if(_useEncryption)
{
_mqttClientSecure->setCleanSession(cleanSession);
}
else
{
_mqttClient->setCleanSession(cleanSession);
}
}
uint16_t EthLan8720Device::mqttPublish(const char *topic, uint8_t qos, bool retain, const char *payload)
{
if(_useEncryption)
{
return _mqttClientSecure->publish(topic, qos, retain, payload);
}
else
{
return _mqttClient->publish(topic, qos, retain, payload);
}
}
uint16_t EthLan8720Device::mqttPublish(const char *topic, uint8_t qos, bool retain, const uint8_t *payload, size_t length)
{
if(_useEncryption)
{
return _mqttClientSecure->publish(topic, qos, retain, payload, length);
}
else
{
return _mqttClient->publish(topic, qos, retain, payload, length);
}
}
bool EthLan8720Device::mqttConnected() const
{
if(_useEncryption)
{
return _mqttClientSecure->connected();
}
else
{
return _mqttClient->connected();
}
}
void EthLan8720Device::mqttSetServer(const char *host, uint16_t port)
{
if(_useEncryption)
{
_mqttClientSecure->setServer(host, port);
}
else
{
_mqttClient->setServer(host, port);
}
}
bool EthLan8720Device::mqttConnect()
{
if(_useEncryption)
{
return _mqttClientSecure->connect();
}
else
{
return _mqttClient->connect();
}
}
bool EthLan8720Device::mqttDisconnect(bool force)
{
if(_useEncryption)
{
return _mqttClientSecure->disconnect(force);
}
else
{
return _mqttClient->disconnect(force);
}
}
void EthLan8720Device::setWill(const char *topic, uint8_t qos, bool retain, const char *payload)
{
if(_useEncryption)
{
_mqttClientSecure->setWill(topic, qos, retain, payload);
}
else
{
_mqttClient->setWill(topic, qos, retain, payload);
}
}
void EthLan8720Device::mqttSetCredentials(const char *username, const char *password)
{
if(_useEncryption)
{
_mqttClientSecure->setCredentials(username, password);
}
else
{
_mqttClient->setCredentials(username, password);
}
}
void EthLan8720Device::mqttOnMessage(espMqttClientTypes::OnMessageCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onMessage(callback);
}
else
{
_mqttClient->onMessage(callback);
}
}
void EthLan8720Device::mqttOnConnect(espMqttClientTypes::OnConnectCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onConnect(callback);
}
else
{
_mqttClient->onConnect(callback);
}
}
void EthLan8720Device::mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onDisconnect(callback);
}
else
{
_mqttClient->onDisconnect(callback);
}
}
uint16_t EthLan8720Device::mqttSubscribe(const char *topic, uint8_t qos)
{
if(_useEncryption)
{
return _mqttClientSecure->subscribe(topic, qos);
}
else
{
return _mqttClient->subscribe(topic, qos);
}
}
void EthLan8720Device::disableMqtt()
{
if (_useEncryption)
{
_mqttClientSecure->disconnect();
} else
{
_mqttClient->disconnect();
}
_mqttEnabled = false;
}

View File

@@ -28,57 +28,20 @@ public:
virtual void initialize();
virtual void reconfigure();
virtual ReconnectStatus reconnect();
virtual void printError();
bool supportsEncryption() override;
virtual void update();
virtual bool isConnected();
int8_t signalStrength() override;
String localIP() override;
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;
bool mqttDisconnect(bool force) override;
void setWill(const char *topic, uint8_t qos, bool retain, const char *payload) override;
void mqttSetCredentials(const char *username, const char *password) override;
void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) override;
void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) override;
void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) override;
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
void disableMqtt() override;
private:
void onDisconnected();
espMqttClient* _mqttClient = nullptr;
espMqttClientSecure* _mqttClientSecure = nullptr;
bool _restartOnDisconnect = false;
bool _startAp = false;
char* _path;
bool _useEncryption = false;
bool _hardwareInitialized = false;
bool _lastConnected = false;
@@ -90,7 +53,6 @@ private:
eth_phy_type_t _type;
eth_clock_mode_t _clock_mode;
bool _use_mac_from_efuse;
bool _mqttEnabled = true;
char _ca[TLS_CA_MAX_SIZE] = {0};
char _cert[TLS_CERT_MAX_SIZE] = {0};

View File

@@ -0,0 +1,161 @@
#include <Arduino.h>
#include "NetworkDevice.h"
#include "../Logger.h"
void NetworkDevice::printError()
{
Log->print(F("Free Heap: "));
Log->println(ESP.getFreeHeap());
}
void NetworkDevice::update()
{
if (_mqttEnabled)
{
getMqttClient()->loop();
}
}
void NetworkDevice::mqttSetClientId(const char *clientId)
{
if (_useEncryption)
{
_mqttClientSecure->setClientId(clientId);
}
else
{
_mqttClient->setClientId(clientId);
}
}
void NetworkDevice::mqttSetCleanSession(bool cleanSession)
{
if (_useEncryption)
{
_mqttClientSecure->setCleanSession(cleanSession);
}
else
{
_mqttClient->setCleanSession(cleanSession);
}
}
uint16_t NetworkDevice::mqttPublish(const char *topic, uint8_t qos, bool retain, const char *payload)
{
return getMqttClient()->publish(topic, qos, retain, payload);
}
uint16_t NetworkDevice::mqttPublish(const char *topic, uint8_t qos, bool retain, const uint8_t *payload, size_t length)
{
return getMqttClient()->publish(topic, qos, retain, payload, length);
}
bool NetworkDevice::mqttConnected() const
{
return getMqttClient()->connected();
}
void NetworkDevice::mqttSetServer(const char *host, uint16_t port)
{
if (_useEncryption)
{
_mqttClientSecure->setServer(host, port);
}
else
{
_mqttClient->setServer(host, port);
}
}
bool NetworkDevice::mqttConnect()
{
return getMqttClient()->connect();
}
bool NetworkDevice::mqttDisconnect(bool force)
{
return getMqttClient()->disconnect(force);
}
void NetworkDevice::setWill(const char *topic, uint8_t qos, bool retain, const char *payload)
{
if (_useEncryption)
{
_mqttClientSecure->setWill(topic, qos, retain, payload);
}
else
{
_mqttClient->setWill(topic, qos, retain, payload);
}
}
void NetworkDevice::mqttSetCredentials(const char *username, const char *password)
{
if (_useEncryption)
{
_mqttClientSecure->setCredentials(username, password);
}
else
{
_mqttClient->setCredentials(username, password);
}
}
void NetworkDevice::mqttOnMessage(espMqttClientTypes::OnMessageCallback callback)
{
if (_useEncryption)
{
_mqttClientSecure->onMessage(callback);
}
else
{
_mqttClient->onMessage(callback);
}
}
void NetworkDevice::mqttOnConnect(espMqttClientTypes::OnConnectCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onConnect(callback);
}
else
{
_mqttClient->onConnect(callback);
}
}
void NetworkDevice::mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback)
{
if (_useEncryption)
{
_mqttClientSecure->onDisconnect(callback);
}
else
{
_mqttClient->onDisconnect(callback);
}
}
uint16_t NetworkDevice::mqttSubscribe(const char *topic, uint8_t qos)
{
return getMqttClient()->subscribe(topic, qos);
}
void NetworkDevice::disableMqtt()
{
getMqttClient()->disconnect();
_mqttEnabled = false;
}
MqttClient *NetworkDevice::getMqttClient() const
{
if (_useEncryption)
{
return _mqttClientSecure;
}
else
{
return _mqttClient;
}
}

View File

@@ -1,6 +1,6 @@
#pragma once
#include "MqttClient.h"
#include "espMqttClient.h"
#include "MqttClientSetup.h"
#include "IPConfiguration.h"
@@ -24,34 +24,42 @@ public:
virtual void initialize() = 0;
virtual ReconnectStatus reconnect() = 0;
virtual void reconfigure() = 0;
virtual void printError() = 0;
virtual void printError();
virtual bool supportsEncryption() = 0;
virtual void update() = 0;
virtual void update();
virtual bool isConnected() = 0;
virtual int8_t signalStrength() = 0;
virtual String localIP() = 0;
virtual void mqttSetClientId(const char* clientId) = 0;
virtual void mqttSetCleanSession(bool cleanSession) = 0;
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const char* payload) = 0;
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const uint8_t* payload, size_t length) = 0;
virtual bool mqttConnected() const = 0;
virtual void mqttSetServer(const char* host, uint16_t port) = 0;
virtual bool mqttConnect() = 0;
virtual bool mqttDisconnect(bool force) = 0;
virtual void setWill(const char* topic, uint8_t qos, bool retain, const char* payload) = 0;
virtual void mqttSetCredentials(const char* username, const char* password) = 0;
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) = 0;
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) = 0;
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) = 0;
virtual void disableMqtt() = 0;
virtual void mqttSetClientId(const char* clientId);
virtual void mqttSetCleanSession(bool cleanSession);
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const char* payload);
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const uint8_t* payload, size_t length);
virtual bool mqttConnected() const;
virtual void mqttSetServer(const char* host, uint16_t port);
virtual bool mqttConnect();
virtual bool mqttDisconnect(bool force);
virtual void setWill(const char* topic, uint8_t qos, bool retain, const char* payload);
virtual void mqttSetCredentials(const char* username, const char* password);
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback);
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback);
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback);
virtual void disableMqtt();
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos) = 0;
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos);
protected:
espMqttClient *_mqttClient = nullptr;
espMqttClientSecure *_mqttClientSecure = nullptr;
bool _useEncryption = false;
bool _mqttEnabled = true;
const String _hostname;
const IPConfiguration* _ipConfiguration = nullptr;
MqttClient *getMqttClient() const;
};

View File

@@ -26,6 +26,8 @@ W5500Device::W5500Device(const String &hostname, Preferences* preferences, const
}
}
Log->println();
_mqttClient = new espMqttClientW5500();
}
W5500Device::~W5500Device()
@@ -61,7 +63,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(*getMqttClient(), _path, MqttLoggerMode::MqttAndSerial);
}
reconnect();
@@ -161,13 +163,6 @@ void W5500Device::resetDevice()
delay(50);
}
void W5500Device::printError()
{
Log->print(F("Free Heap: "));
Log->println(ESP.getFreeHeap());
}
bool W5500Device::supportsEncryption()
{
return false;
@@ -218,10 +213,7 @@ void W5500Device::initializeMacAddress(byte *mac)
void W5500Device::update()
{
_maintainResult = Ethernet.maintain();
if(_mqttEnabled)
{
_mqttClient.loop();
}
NetworkDevice::update();
}
int8_t W5500Device::signalStrength()
@@ -233,79 +225,3 @@ String W5500Device::localIP()
{
return Ethernet.localIP().toString();
}
void W5500Device::mqttSetClientId(const char *clientId)
{
_mqttClient.setClientId(clientId);
}
void W5500Device::mqttSetCleanSession(bool cleanSession)
{
_mqttClient.setCleanSession(cleanSession);
}
uint16_t W5500Device::mqttPublish(const char *topic, uint8_t qos, bool retain, const char *payload)
{
return _mqttClient.publish(topic, qos, retain, payload);
}
bool W5500Device::mqttConnected() const
{
return _mqttClient.connected();
}
void W5500Device::mqttSetServer(const char *host, uint16_t port)
{
_mqttClient.setServer(host, port);
}
bool W5500Device::mqttConnect()
{
return _mqttClient.connect();
}
bool W5500Device::mqttDisconnect(bool force)
{
return _mqttClient.disconnect(force);
}
void W5500Device::setWill(const char *topic, uint8_t qos, bool retain, const char *payload)
{
_mqttClient.setWill(topic, qos, retain, payload);
}
void W5500Device::mqttSetCredentials(const char *username, const char *password)
{
_mqttClient.setCredentials(username, password);
}
void W5500Device::mqttOnMessage(espMqttClientTypes::OnMessageCallback callback)
{
_mqttClient.onMessage(callback);
}
void W5500Device::mqttOnConnect(espMqttClientTypes::OnConnectCallback callback)
{
_mqttClient.onConnect(callback);
}
void W5500Device::mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback)
{
_mqttClient.onDisconnect(callback);
}
uint16_t W5500Device::mqttSubscribe(const char *topic, uint8_t qos)
{
return _mqttClient.subscribe(topic, qos);
}
uint16_t W5500Device::mqttPublish(const char *topic, uint8_t qos, bool retain, const uint8_t *payload, size_t length)
{
return _mqttClient.publish(topic, qos, retain, payload, length);
}
void W5500Device::disableMqtt()
{
_mqttClient.disconnect();
_mqttEnabled = false;
}

View File

@@ -23,11 +23,10 @@ public:
virtual void initialize();
virtual ReconnectStatus reconnect();
virtual void reconfigure();
virtual void printError();
bool supportsEncryption() override;
virtual void update();
virtual void update() override;
virtual bool isConnected();
@@ -35,41 +34,10 @@ public:
String localIP() override;
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;
bool mqttDisconnect(bool force) override;
void setWill(const char *topic, uint8_t qos, bool retain, const char *payload) override;
void mqttSetCredentials(const char *username, const char *password) override;
void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) override;
void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) override;
void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) override;
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
void disableMqtt() override;
private:
void resetDevice();
void initializeMacAddress(byte* mac);
espMqttClientW5500 _mqttClient;
Preferences* _preferences = nullptr;
int _maintainResult = 0;
@@ -78,7 +46,6 @@ private:
char* _path;
W5500Variant _variant;
bool _lastConnected = false;
bool _mqttEnabled = true;
byte _mac[6];
};

View File

@@ -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);
}
}
@@ -125,18 +125,6 @@ void WifiDevice::reconfigure()
restartEsp(RestartReason::ReconfigureWifi);
}
void WifiDevice::printError()
{
// if(_wifiClientSecure != nullptr)
// {
// char lastError[100];
// _wifiClientSecure->lastError(lastError,100);
// Log->println(lastError);
// }
Log->print(F("Free Heap: "));
Log->println(ESP.getFreeHeap());
}
bool WifiDevice::supportsEncryption()
{
return true;
@@ -153,20 +141,6 @@ ReconnectStatus WifiDevice::reconnect()
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
}
void WifiDevice::update()
{
if(_mqttEnabled)
{
if (_useEncryption)
{
_mqttClientSecure->loop();
} else
{
_mqttClient->loop();
}
}
}
void WifiDevice::onDisconnected()
{
if(millis() > 60000)
@@ -189,186 +163,3 @@ void WifiDevice::clearRtcInitVar(WiFiManager *)
{
memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect);
}
void WifiDevice::mqttSetClientId(const char *clientId)
{
if(_useEncryption)
{
_mqttClientSecure->setClientId(clientId);
}
else
{
_mqttClient->setClientId(clientId);
}
}
void WifiDevice::mqttSetCleanSession(bool cleanSession)
{
if(_useEncryption)
{
_mqttClientSecure->setCleanSession(cleanSession);
}
else
{
_mqttClient->setCleanSession(cleanSession);
}
}
uint16_t WifiDevice::mqttPublish(const char *topic, uint8_t qos, bool retain, const char *payload)
{
if(_useEncryption)
{
return _mqttClientSecure->publish(topic, qos, retain, payload);
}
else
{
return _mqttClient->publish(topic, qos, retain, payload);
}
}
uint16_t WifiDevice::mqttPublish(const char *topic, uint8_t qos, bool retain, const uint8_t *payload, size_t length)
{
if(_useEncryption)
{
return _mqttClientSecure->publish(topic, qos, retain, payload, length);
}
else
{
return _mqttClient->publish(topic, qos, retain, payload, length);
}
}
bool WifiDevice::mqttConnected() const
{
if(_useEncryption)
{
return _mqttClientSecure->connected();
}
else
{
return _mqttClient->connected();
}
}
void WifiDevice::mqttSetServer(const char *host, uint16_t port)
{
if(_useEncryption)
{
_mqttClientSecure->setServer(host, port);
}
else
{
_mqttClient->setServer(host, port);
}
}
bool WifiDevice::mqttConnect()
{
if(_useEncryption)
{
return _mqttClientSecure->connect();
}
else
{
return _mqttClient->connect();
}
}
bool WifiDevice::mqttDisconnect(bool force)
{
if(_useEncryption)
{
return _mqttClientSecure->disconnect(force);
}
else
{
return _mqttClient->disconnect(force);
}
}
void WifiDevice::setWill(const char *topic, uint8_t qos, bool retain, const char *payload)
{
if(_useEncryption)
{
_mqttClientSecure->setWill(topic, qos, retain, payload);
}
else
{
_mqttClient->setWill(topic, qos, retain, payload);
}
}
void WifiDevice::mqttSetCredentials(const char *username, const char *password)
{
if(_useEncryption)
{
_mqttClientSecure->setCredentials(username, password);
}
else
{
_mqttClient->setCredentials(username, password);
}
}
void WifiDevice::mqttOnMessage(espMqttClientTypes::OnMessageCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onMessage(callback);
}
else
{
_mqttClient->onMessage(callback);
}
}
void WifiDevice::mqttOnConnect(espMqttClientTypes::OnConnectCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onConnect(callback);
}
else
{
_mqttClient->onConnect(callback);
}
}
void WifiDevice::mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback)
{
if(_useEncryption)
{
_mqttClientSecure->onDisconnect(callback);
}
else
{
_mqttClient->onDisconnect(callback);
}
}
uint16_t WifiDevice::mqttSubscribe(const char *topic, uint8_t qos)
{
if(_useEncryption)
{
return _mqttClientSecure->subscribe(topic, qos);
}
else
{
return _mqttClient->subscribe(topic, qos);
}
}
void WifiDevice::disableMqtt()
{
if (_useEncryption)
{
_mqttClientSecure->disconnect();
} else
{
_mqttClient->disconnect();
}
_mqttEnabled = false;
}

View File

@@ -18,62 +18,25 @@ public:
virtual void initialize();
virtual void reconfigure();
virtual ReconnectStatus reconnect();
virtual void printError();
bool supportsEncryption() override;
virtual void update();
virtual bool isConnected();
int8_t signalStrength() override;
String localIP() override;
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;
bool mqttDisconnect(bool force) override;
void setWill(const char *topic, uint8_t qos, bool retain, const char *payload) override;
void mqttSetCredentials(const char *username, const char *password) override;
void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback) override;
void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback) override;
void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback) override;
uint16_t mqttSubscribe(const char *topic, uint8_t qos) override;
void disableMqtt() override;
private:
static void clearRtcInitVar(WiFiManager*);
void onDisconnected();
WiFiManager _wm;
espMqttClient* _mqttClient = nullptr;
espMqttClientSecure* _mqttClientSecure = nullptr;
Preferences* _preferences = nullptr;
bool _restartOnDisconnect = false;
bool _startAp = false;
char* _path;
bool _useEncryption = false;
bool _mqttEnabled = true;
char _ca[TLS_CA_MAX_SIZE] = {0};
char _cert[TLS_CERT_MAX_SIZE] = {0};

View File

@@ -1,7 +1,7 @@
#include "espMqttClientW5500.h"
espMqttClientW5500::espMqttClientW5500()
: MqttClientSetup(espMqttClientTypes::UseInternalTask::NO),
: espMqttClient(espMqttClientTypes::UseInternalTask::NO),
_client()
{
_transport = &_client;

View File

@@ -1,9 +1,9 @@
#pragma once
#include "MqttClientSetup.h"
#include "espMqttClient.h"
#include "ClientSyncW5500.h"
class espMqttClientW5500 : public MqttClientSetup<espMqttClientW5500> {
class espMqttClientW5500 : public espMqttClient {
public:
#if defined(ARDUINO_ARCH_ESP32)
explicit espMqttClientW5500();