Unverified Commit 99aa8664 authored by thebigpotatoe's avatar thebigpotatoe Committed by GitHub

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.
parent 82670b96
...@@ -130,7 +130,7 @@ void MDNSResponder::disableWorkstation(){ ...@@ -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 _name[strlen(name)+2];
char _proto[strlen(proto)+2]; char _proto[strlen(proto)+2];
if (name[0] == '_') { if (name[0] == '_') {
...@@ -146,7 +146,9 @@ void MDNSResponder::addService(char *name, char *proto, uint16_t port){ ...@@ -146,7 +146,9 @@ void MDNSResponder::addService(char *name, char *proto, uint16_t port){
if(mdns_service_add(NULL, _name, _proto, port, NULL, 0)) { if(mdns_service_add(NULL, _name, _proto, port, NULL, 0)) {
log_e("Failed adding service %s.%s.\n", name, proto); 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){ bool MDNSResponder::addServiceTxt(char *name, char *proto, char *key, char *value){
......
...@@ -65,12 +65,12 @@ public: ...@@ -65,12 +65,12 @@ public:
setInstanceName(String(name)); setInstanceName(String(name));
} }
void addService(char *service, char *proto, uint16_t port); bool addService(char *service, char *proto, uint16_t port);
void addService(const char *service, const char *proto, uint16_t port){ bool addService(const char *service, const char *proto, uint16_t port){
addService((char *)service, (char *)proto, port); return addService((char *)service, (char *)proto, port);
} }
void addService(String service, String proto, uint16_t port){ bool addService(String service, String proto, uint16_t port){
addService(service.c_str(), proto.c_str(), port); return addService(service.c_str(), proto.c_str(), port);
} }
bool addServiceTxt(char *name, char *proto, char * key, char * value); bool addServiceTxt(char *name, char *proto, char * key, char * value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment