Skip to content
Merged
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
12 changes: 8 additions & 4 deletions libraries/SimpleMDNS/src/SimpleMDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void SimpleMDNS::enableArduino(unsigned int port, bool passwd) {
return;
}
SimpleMDNSService *svc = new SimpleMDNSService();
svc->_service = "arduino";
svc->_service = strdup("arduino");
svc->_proto = DNSSD_PROTO_TCP;
svc->_port = port;
svc->_fn = _arduinoGetTxt;
Expand Down Expand Up @@ -140,7 +140,13 @@ void SimpleMDNS::end() {
__setStateChangeCallback(nullptr);
__setAddNetifCallback(nullptr);
__setRemoveNetifCallback(nullptr);

for (auto svc : _svcMap) {
free(svc.second->_service);
delete svc.second;
}
_svcMap.clear();
free(_hostname);
_arduinoAdded = false;
}
_running = false;
}
Expand Down Expand Up @@ -219,6 +225,4 @@ hMDNSTxt SimpleMDNS::addServiceTxt(const hMDNSService p_hService, const char* p_
}


const char *SimpleMDNS::_hostname = nullptr;

SimpleMDNS MDNS;
6 changes: 3 additions & 3 deletions libraries/SimpleMDNS/src/SimpleMDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SimpleMDNSService {
static void callback(struct mdns_service *service, void *txt_userdata);
hMDNSTxt add(const char *key, const char *val);

const char *_service;
char *_service;
uint16_t _proto;
uint16_t _port;
service_get_txt_fn_t _fn;
Expand Down Expand Up @@ -80,8 +80,8 @@ class SimpleMDNS {

bool _running = false;
bool _lwipMSNDInitted = false;
static const char *_hostname;
std::map<std::string, SimpleMDNSService*> _svcMap;
char *_hostname;
std::map<const char *, SimpleMDNSService*> _svcMap;
bool _arduinoAdded = false;

// LwipIntfDev helpers when netifs come up and down, to ensure we set the old services on the new netif
Expand Down