From f7d8a027e8b8578cf5b27b3805c2ba172558d3c0 Mon Sep 17 00:00:00 2001 From: Eric Wilkison Date: Thu, 17 Dec 2015 14:29:15 -0800 Subject: [PATCH] Fix begin overwriting instancename --- libraries/ESP8266mDNS/ESP8266mDNS.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/ESP8266mDNS/ESP8266mDNS.cpp b/libraries/ESP8266mDNS/ESP8266mDNS.cpp index 9879e665d..304b93724 100644 --- a/libraries/ESP8266mDNS/ESP8266mDNS.cpp +++ b/libraries/ESP8266mDNS/ESP8266mDNS.cpp @@ -85,7 +85,10 @@ static const IPAddress MDNS_MULTICAST_ADDR(224, 0, 0, 251); static const int MDNS_MULTICAST_TTL = 1; static const int MDNS_PORT = 5353; -MDNSResponder::MDNSResponder() : _conn(0) { _services = 0; } +MDNSResponder::MDNSResponder() : _conn(0) { + _services = 0; + _instanceName[0] = 0; +} MDNSResponder::~MDNSResponder() {} bool MDNSResponder::begin(const char* hostname){ @@ -101,8 +104,8 @@ bool MDNSResponder::begin(const char* hostname){ _hostName[i] = tolower(hostname[i]); _hostName[n] = '\0'; - // Copy hostname to default instance name - os_strcpy(_instanceName,hostname); + // If instance name is not already set copy hostname to instance name + if (os_strlen(_instanceName) == 0) os_strcpy(_instanceName,hostname); // Open the MDNS socket if it isn't already open. if (!_conn) {