mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
Remove mDNS resets
This commit is contained in:
parent
574b2ece04
commit
edc4f103d2
7 changed files with 24 additions and 4 deletions
22
Network.cpp
22
Network.cpp
|
|
@ -54,7 +54,10 @@ void Network::loop() {
|
|||
this->emitSockets();
|
||||
if(!this->connected()) return;
|
||||
}
|
||||
if(this->connected() && millis() - this->lastMDNS > 10000) {
|
||||
if(this->connected() && millis() - this->lastMDNS > 60000) {
|
||||
// We are doing this every 60 seconds because of the BS related to
|
||||
// the MDNS library. The original library required manual updates
|
||||
// to the MDNS or it would lose its hostname after 2 minutes.
|
||||
if(this->lastMDNS != 0) MDNS.setInstanceName(settings.hostname);
|
||||
this->lastMDNS = millis();
|
||||
}
|
||||
|
|
@ -260,6 +263,23 @@ bool Network::connectWired() {
|
|||
if(this->connectAttempts > 10) this->wifiFallback = true;
|
||||
return false;
|
||||
}
|
||||
void Network::updateHostname() {
|
||||
if(settings.hostname[0] != '\0' && this->connected()) {
|
||||
if(this->connType == conn_types::ethernet &&
|
||||
strcmp(settings.hostname, ETH.getHostname()) != 0) {
|
||||
Serial.printf("Updating host name to %s...\n", settings.hostname);
|
||||
ETH.setHostname(settings.hostname);
|
||||
MDNS.setInstanceName(settings.hostname);
|
||||
SSDP.setName(0, settings.hostname);
|
||||
}
|
||||
else if(strcmp(settings.hostname, WiFi.getHostname()) != 0) {
|
||||
Serial.printf("Updating host name to %s...\n", settings.hostname);
|
||||
WiFi.setHostname(settings.hostname);
|
||||
MDNS.setInstanceName(settings.hostname);
|
||||
SSDP.setName(0, settings.hostname);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool Network::connectWiFi() {
|
||||
if(settings.WIFI.ssid[0] != '\0') {
|
||||
if(WiFi.status() == WL_CONNECTED && WiFi.SSID().compareTo(settings.WIFI.ssid) == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue