Changing mDNS hostname on the fly
Posted: Thu Jan 18, 2018 10:57 am
Hi all,
Initially I set the mds.hostname in setup with something like
Is it possible / advisable to change the hostname on the fly in the loop just by calling MDNS.begin again?
E.G.
Initially I set the mds.hostname in setup with something like
Code: Select all
void 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!");
}
}
...
}