Update MDNSResponder::addService to return a boolean (#4365)

I was playing with the mDNS service and noticed the method MDNSResponder::addService could return a Boolean with the way it is implemented just like other functions in this library.

This would be handy to know at a higher level weather or not the service was added correctly to the mDNS server of the ESP32.
This commit is contained in:
thebigpotatoe 2020-10-01 22:44:24 +10:00 committed by GitHub
parent 82670b96f8
commit 99aa866477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -130,7 +130,7 @@ void MDNSResponder::disableWorkstation(){
}
}
void MDNSResponder::addService(char *name, char *proto, uint16_t port){
bool MDNSResponder::addService(char *name, char *proto, uint16_t port){
char _name[strlen(name)+2];
char _proto[strlen(proto)+2];
if (name[0] == '_') {
@ -146,7 +146,9 @@ void MDNSResponder::addService(char *name, char *proto, uint16_t port){
if(mdns_service_add(NULL, _name, _proto, port, NULL, 0)) {
log_e("Failed adding service %s.%s.\n", name, proto);
return false;
}
return true;
}
bool MDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *value){

View File

@ -65,12 +65,12 @@ public:
setInstanceName(String(name));
}
void addService(char *service, char *proto, uint16_t port);
void addService(const char *service, const char *proto, uint16_t port){
addService((char *)service, (char *)proto, port);
bool addService(char *service, char *proto, uint16_t port);
bool addService(const char *service, const char *proto, uint16_t port){
return addService((char *)service, (char *)proto, port);
}
void addService(String service, String proto, uint16_t port){
addService(service.c_str(), proto.c_str(), port);
bool addService(String service, String proto, uint16_t port){
return addService(service.c_str(), proto.c_str(), port);
}
bool addServiceTxt(char *name, char *proto, char * key, char * value);