mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
Merge pull request #1451 from probonopd/patch-2
advertise all hosted services
This commit is contained in:
@ -366,6 +366,10 @@ void MDNSResponder::_parsePacket(){
|
|||||||
memmove(protoName, protoName+1, protoNameLen);
|
memmove(protoName, protoName+1, protoNameLen);
|
||||||
protoNameLen--;
|
protoNameLen--;
|
||||||
protoParsed = true;
|
protoParsed = true;
|
||||||
|
} else if(strcmp("services", serviceName) == 0 && strcmp("_dns-sd", protoName) == 0){
|
||||||
|
_conn->flush();
|
||||||
|
advertiseServices();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
#ifdef MDNS_DEBUG_ERR
|
#ifdef MDNS_DEBUG_ERR
|
||||||
Serial.printf("ERR_PROTO: %s\n", protoName);
|
Serial.printf("ERR_PROTO: %s\n", protoName);
|
||||||
@ -479,6 +483,18 @@ void MDNSResponder::enableArduino(uint16_t port, bool auth){
|
|||||||
addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes":"no");
|
addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes":"no");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t MDNSResponder::advertiseServices(){
|
||||||
|
MDNSService* servicePtr;
|
||||||
|
size_t i = 0;
|
||||||
|
for (servicePtr = _services; servicePtr; servicePtr = servicePtr->_next) {
|
||||||
|
if(servicePtr->_port > 0){
|
||||||
|
_reply(0x0F, servicePtr->_name, servicePtr->_proto, servicePtr->_port);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint16_t port){
|
void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint16_t port){
|
||||||
int i;
|
int i;
|
||||||
if(replyMask == 0) return;
|
if(replyMask == 0) return;
|
||||||
|
@ -104,6 +104,7 @@ private:
|
|||||||
uint16_t _getServiceTxtLen(char *name, char *proto);
|
uint16_t _getServiceTxtLen(char *name, char *proto);
|
||||||
void _parsePacket();
|
void _parsePacket();
|
||||||
void _reply(uint8_t replyMask, char * service, char *proto, uint16_t port);
|
void _reply(uint8_t replyMask, char * service, char *proto, uint16_t port);
|
||||||
|
size_t advertiseServices(); // advertise all hosted services
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MDNSResponder MDNS;
|
extern MDNSResponder MDNS;
|
||||||
|
Reference in New Issue
Block a user