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) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class Network {
|
|||
void setConnected(conn_types connType);
|
||||
int getStrengthByMac(const char *mac);
|
||||
int getStrengthBySSID(const char *ssid);
|
||||
void updateHostname();
|
||||
bool setup();
|
||||
void loop();
|
||||
void end();
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
Web.cpp
1
Web.cpp
|
|
@ -2402,6 +2402,7 @@ void Web::begin() {
|
|||
if (obj.containsKey("hostname") || obj.containsKey("ssdpBroadcast")) {
|
||||
settings.fromJSON(obj);
|
||||
settings.save();
|
||||
net.updateHostname();
|
||||
}
|
||||
if (obj.containsKey("ntpServer") || obj.containsKey("ntpServer")) {
|
||||
settings.NTP.fromJSON(obj);
|
||||
|
|
|
|||
|
|
@ -631,12 +631,9 @@ div.wait-overlay > .lds-roller {
|
|||
}
|
||||
.somfyShadeCtl .shade-icon {
|
||||
display: inline-block;
|
||||
padding-top: 7px;
|
||||
padding-bottom: 7px;
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
vertical-align: middle;
|
||||
margin-top: -5px;
|
||||
font-size: 48px;
|
||||
position:relative;
|
||||
}
|
||||
|
|
@ -654,6 +651,7 @@ div.wait-overlay > .lds-roller {
|
|||
}
|
||||
.somfyGroupCtl .groupctl-shades {
|
||||
font-size:12px;
|
||||
margin-top:-3px;
|
||||
}
|
||||
.somfyGroupCtl .groupctl-name,
|
||||
.somfyShadeCtl .shadectl-name {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue