Skip to content

Commit f7d8a02

Browse files
author
Eric Wilkison
committed
Fix begin overwriting instancename
1 parent 99b3e2d commit f7d8a02

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

libraries/ESP8266mDNS/ESP8266mDNS.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ static const IPAddress MDNS_MULTICAST_ADDR(224, 0, 0, 251);
8585
static const int MDNS_MULTICAST_TTL = 1;
8686
static const int MDNS_PORT = 5353;
8787

88-
MDNSResponder::MDNSResponder() : _conn(0) { _services = 0; }
88+
MDNSResponder::MDNSResponder() : _conn(0) {
89+
_services = 0;
90+
_instanceName[0] = 0;
91+
}
8992
MDNSResponder::~MDNSResponder() {}
9093

9194
bool MDNSResponder::begin(const char* hostname){
@@ -101,8 +104,8 @@ bool MDNSResponder::begin(const char* hostname){
101104
_hostName[i] = tolower(hostname[i]);
102105
_hostName[n] = '\0';
103106

104-
// Copy hostname to default instance name
105-
os_strcpy(_instanceName,hostname);
107+
// If instance name is not already set copy hostname to instance name
108+
if (os_strlen(_instanceName) == 0) os_strcpy(_instanceName,hostname);
106109

107110
// Open the MDNS socket if it isn't already open.
108111
if (!_conn) {

0 commit comments

Comments
 (0)