-->
Page 1 of 1

Changing mDNS hostname on the fly

PostPosted: Thu Jan 18, 2018 10:57 am
by thedroid
Hi all,

Initially I set the mds.hostname in setup with something like

Code: Select allvoid setup() {
....
if (!MDNS.begin(hostString)) {
    Serial.println("Error setting up MDNS responder!");
  }
 
MDNS.addService("http", "tcp", 80);

...

}


Is it possible / advisable to change the hostname on the fly in the loop just by calling MDNS.begin again?
E.G.

Code: Select all
void loop() {
  ...
  if (_newHostname)
  {
    _newHostname = false;
    if (!MDNS.begin(updatedhostName)) {
      Serial.println("Error setting up MDNS responder!");
    }
 
  }
  ...
}