Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PR306 for ESP8266 #312

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/AsyncMqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ AsyncMqttClient& AsyncMqttClient::setServer(const char* serviceName, const char*
_serviceName = serviceName;
_protocol = protocol;

#ifdef ESP32
// std::cout << "host name: " << hostName << std::endl;
if (_hostName != "") {
if (MDNS.begin(_hostName)) { // Nome do host do ESP32
Expand All @@ -146,6 +147,9 @@ AsyncMqttClient& AsyncMqttClient::setServer(const char* serviceName, const char*
}
}
}
#else
return *this;
#endif
}

AsyncMqttClient& AsyncMqttClient::setHostName(const char* hostName) {
Expand Down
7 changes: 4 additions & 3 deletions src/AsyncMqttClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
#include <ESPmDNS.h>
#include <Preferences.h>
#include <freertos/semphr.h>
#include <ESPmDNS.h>
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESPAsyncTCP.h>
#include <ESPmDNS.h>
#else
#error Platform not supported
#endif
#include <WiFi.h>

#if ASYNC_TCP_SSL_ENABLED
#include <tcp_axtls.h>
Expand Down Expand Up @@ -106,8 +106,9 @@ class AsyncMqttClient {
uint32_t _lastClientActivity;
uint32_t _lastServerActivity;
uint32_t _lastPingRequestTime;
#ifdef ESP32
Preferences preferences;

#endif
char _generatedClientId[18 + 1]; // esp8266-abc123 and esp32-abcdef123456
IPAddress _ip;
const char* _host;
Expand Down