diff --git a/Network.cpp b/Network.cpp index c67878f..fb38a69 100644 --- a/Network.cpp +++ b/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) { diff --git a/Network.h b/Network.h index 18d9f25..7120262 100644 --- a/Network.h +++ b/Network.h @@ -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(); diff --git a/SomfyController.ino.esp32.bin b/SomfyController.ino.esp32.bin index 08fdf93..4e8e755 100644 Binary files a/SomfyController.ino.esp32.bin and b/SomfyController.ino.esp32.bin differ diff --git a/SomfyController.ino.esp32s3.bin b/SomfyController.ino.esp32s3.bin index 95c492c..153e8cd 100644 Binary files a/SomfyController.ino.esp32s3.bin and b/SomfyController.ino.esp32s3.bin differ diff --git a/SomfyController.littlefs.bin b/SomfyController.littlefs.bin index 2269ca2..d596cef 100644 Binary files a/SomfyController.littlefs.bin and b/SomfyController.littlefs.bin differ diff --git a/Web.cpp b/Web.cpp index 33929d3..522cd0d 100644 --- a/Web.cpp +++ b/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); diff --git a/data/main.css b/data/main.css index 1233442..7fd28d8 100644 --- a/data/main.css +++ b/data/main.css @@ -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 {