Skip to content

Commit 7a35ee4

Browse files
committed
advertise all hosted services (written by me-no-dev)
1 parent 0b42f53 commit 7a35ee4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

libraries/ESP8266mDNS/ESP8266mDNS.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ void MDNSResponder::_parsePacket(){
366366
memmove(protoName, protoName+1, protoNameLen);
367367
protoNameLen--;
368368
protoParsed = true;
369+
} else if(strcmp("services", serviceName) == 0 && strcmp("_dns-sd", protoName) == 0){
370+
_conn->flush();
371+
advertiseServices();
372+
return;
369373
} else {
370374
#ifdef MDNS_DEBUG_ERR
371375
Serial.printf("ERR_PROTO: %s\n", protoName);
@@ -479,6 +483,18 @@ void MDNSResponder::enableArduino(uint16_t port, bool auth){
479483
addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes":"no");
480484
}
481485

486+
size_t MDNSResponder::advertiseServices(){
487+
MDNSService* servicePtr;
488+
size_t i = 0;
489+
for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next) {
490+
if(servicePtr->_port > 0){
491+
_reply(0x0F, servicePtr->_name, servicePtr->_proto, servicePtr->_port);
492+
i++;
493+
}
494+
}
495+
return i;
496+
}
497+
482498
void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint16_t port){
483499
int i;
484500
if(replyMask == 0) return;

0 commit comments

Comments
 (0)