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

Only add MDNS services if MDNS is enabled (default=true) #1

Open
wants to merge 1 commit into
base: main
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: 3 additions & 1 deletion src/TelnetSerialStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ void TelnetSerialStream::begin() {
_serverClients[i] = NULL;

Log.printf("Opened serial server on telnet://%s:%d\n", WiFi.localIP().toString().c_str(), _telnetPort);
MDNS.addService("telnet", "tcp", _telnetPort);
if (_withMDNS) {
MDNS.addService("telnet", "tcp", _telnetPort);
}
};

void TelnetSerialStream::stop() {
Expand Down
5 changes: 3 additions & 2 deletions src/TelnetSerialStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

class TelnetSerialStream : public LOGBase {
public:
TelnetSerialStream(String hostname, const uint16_t telnetPort = 23, const uint16_t maxClients = MAX_SERIAL_TELNET_CLIENTS) : _hostname(hostname), _telnetPort(telnetPort), _maxClients(maxClients) {};
TelnetSerialStream(const uint16_t telnetPort = 23, const uint16_t maxClients = MAX_SERIAL_TELNET_CLIENTS) : _telnetPort(telnetPort), _maxClients(maxClients) {};
TelnetSerialStream(String hostname, const uint16_t telnetPort = 23, const uint16_t maxClients = MAX_SERIAL_TELNET_CLIENTS, bool withMDNS = true) : _hostname(hostname), _telnetPort(telnetPort), _maxClients(maxClients), _withMDNS(withMDNS) {};
TelnetSerialStream(const uint16_t telnetPort = 23, const uint16_t maxClients = MAX_SERIAL_TELNET_CLIENTS, bool withMDNS = true) : _telnetPort(telnetPort), _maxClients(maxClients), _withMDNS(withMDNS) {};
~TelnetSerialStream();
virtual size_t write(uint8_t c);
virtual size_t write(uint8_t * buff, size_t len);
Expand All @@ -43,6 +43,7 @@ class TelnetSerialStream : public LOGBase {
uint16_t _telnetPort, _maxClients;
WiFiServer * _server = NULL;
WiFiClient ** _serverClients;
bool _withMDNS;
protected:
};
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/WebSerialStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ void WebSerialStream::begin() {
_server->begin();

Log.printf("Opened serial web server on http://%s:%d\n", WiFi.localIP().toString().c_str(), _webPort);
MDNS.addService("http", "tcp", _webPort);
if (_withMDNS) {
MDNS.addService("http", "tcp", _webPort);
}
};

void WebSerialStream::stop() {
Expand Down
3 changes: 2 additions & 1 deletion src/WebSerialStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef ESP8266WebServer WebServer;

class WebSerialStream : public LOGBase {
public:
WebSerialStream(const uint16_t webPort = 80) : _webPort(webPort) {};
WebSerialStream(const uint16_t webPort = 80, bool withMDNS = true) : _webPort(webPort), _withMDNS(withMDNS) {};
~WebSerialStream();
virtual size_t write(uint8_t c);
virtual void begin();
Expand All @@ -50,6 +50,7 @@ class WebSerialStream : public LOGBase {
WebServer * _server = NULL;
uint8_t _buff[1024];
unsigned long _at = 0;
bool _withMDNS;
protected:
};
#endif
Expand Down