diff --git a/ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino b/ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino index 160f633..3a596b6 100644 --- a/ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino +++ b/ESPTimeCast_ESP32/ESPTimeCast_ESP32.ino @@ -12,6 +12,7 @@ #include #include #include +#include #include "mfactoryfont.h" // Custom font #include "tz_lookup.h" // Timezone lookup, do not duplicate mapping here! @@ -19,7 +20,6 @@ #include "months_lookup.h" // Languages for the Months of the Year #include "index_html.h" // Web UI - #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 #define CLK_PIN 7 //D5 @@ -146,7 +146,7 @@ const unsigned long ntpStatusPrintInterval = 1000; // Print status every 1 seco // Non-blocking IP display globals bool showingIp = false; int ipDisplayCount = 0; -const int ipDisplayMax = 2; // As per working copy for how long IP shows +const int ipDisplayMax = 1; // As per working copy for how long IP shows String pendingIpToShow = ""; // Countdown display state - NEW @@ -520,6 +520,21 @@ void connectWiFi() { } } +// ----------------------------------------------------------------------------- +// mDNS +// ----------------------------------------------------------------------------- +void setupMDNS() { + const char *hostName = "esptimecast"; // your device name + bool mdnsStarted = false; + mdnsStarted = MDNS.begin(hostName); + + if (mdnsStarted) { + MDNS.addService("http", "tcp", 80); + Serial.printf("mDNS started: http://%s.local\n", hostName); + } else { + Serial.println("mDNS failed to start"); + } +} // ----------------------------------------------------------------------------- // Time / NTP Functions @@ -2211,6 +2226,7 @@ void setup() { Serial.println(F("[SETUP] WiFi state is uncertain after connection attempt.")); } + setupMDNS(); setupWebServer(); Serial.println(F("[SETUP] Webserver setup complete")); Serial.println(F("[SETUP] Setup complete")); diff --git a/ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino b/ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino index c79151f..2b7c55f 100644 --- a/ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino +++ b/ESPTimeCast_ESP8266/ESPTimeCast_ESP8266.ino @@ -12,6 +12,7 @@ #include #include #include +#include #include "mfactoryfont.h" // Custom font #include "tz_lookup.h" // Timezone lookup, do not duplicate mapping here! @@ -19,7 +20,6 @@ #include "months_lookup.h" // Languages for the Months of the Year #include "index_html.h" // Web UI - #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 #define CLK_PIN 14 //D5 @@ -92,7 +92,6 @@ int sunriseMinute = 0; int sunsetHour = 18; int sunsetMinute = 0; - //Countdown Globals - NEW bool countdownEnabled = false; time_t countdownTargetTimestamp = 0; // Unix timestamp @@ -147,7 +146,7 @@ const unsigned long ntpStatusPrintInterval = 1000; // Print status every 1 seco // Non-blocking IP display globals bool showingIp = false; int ipDisplayCount = 0; -const int ipDisplayMax = 2; // As per working copy for how long IP shows +const int ipDisplayMax = 1; // As per working copy for how long IP shows String pendingIpToShow = ""; // Countdown display state - NEW @@ -517,6 +516,21 @@ void connectWiFi() { } } +// ----------------------------------------------------------------------------- +// mDNS +// ----------------------------------------------------------------------------- +void setupMDNS() { + const char *hostName = "esptimecast"; // your device name + bool mdnsStarted = false; + mdnsStarted = MDNS.begin(hostName); + + if (mdnsStarted) { + MDNS.addService("http", "tcp", 80); + Serial.printf("mDNS started: http://%s.local\n", hostName); + } else { + Serial.println("mDNS failed to start"); + } +} // ----------------------------------------------------------------------------- // Time / NTP Functions @@ -2204,6 +2218,7 @@ void setup() { Serial.println(F("[SETUP] WiFi state is uncertain after connection attempt.")); } + setupMDNS(); setupWebServer(); Serial.println(F("[SETUP] Webserver setup complete")); Serial.println(F("[SETUP] Setup complete")); @@ -2486,6 +2501,9 @@ void loop() { return; } + // mDNS update 8266 only + MDNS.update(); + // ----------------------------- // Dimming (auto + manual)