Skip to content

Commit 6f5d2c1

Browse files
author
Mike Killewald
committed
ESP8266mDNS - Add support for removing TXT records. Issue esp8266#3212
1 parent 31abb6e commit 6f5d2c1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

libraries/ESP8266mDNS/ESP8266mDNS.cpp

100644100755
+13
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,19 @@ bool MDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *valu
261261
return false;
262262
}
263263

264+
void MDNSResponder::clearServiceTxt(char *name, char *proto){
265+
MDNSService* servicePtr;
266+
//Find the service
267+
for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next) {
268+
//Checking Service names
269+
if(strcmp(servicePtr->_name, name) == 0 && strcmp(servicePtr->_proto, proto) == 0){
270+
//found a service name match
271+
servicePtr->_txts = 0;
272+
servicePtr->_txtLen = 0;
273+
}
274+
}
275+
}
276+
264277
void MDNSResponder::addService(char *name, char *proto, uint16_t port){
265278
if(_getServicePort(name, proto) != 0) return;
266279
if(os_strlen(name) > 32 || os_strlen(proto) != 3) return; //bad arguments

libraries/ESP8266mDNS/ESP8266mDNS.h

100644100755
+8
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class MDNSResponder {
8787
void addServiceTxt(String name, String proto, String key, String value){
8888
addServiceTxt(name.c_str(), proto.c_str(), key.c_str(), value.c_str());
8989
}
90+
91+
void clearServiceTxt(char *name, char *proto);
92+
void clearServiceTxt(const char *name, const char *proto){
93+
clearServiceTxt((char *)name, (char *)proto);
94+
}
95+
void clearServiceTxt(String name, String proto){
96+
clearServiceTxt(name.c_str(), proto.c_str());
97+
}
9098

9199
int queryService(char *service, char *proto);
92100
int queryService(const char *service, const char *proto){

0 commit comments

Comments
 (0)