From 543dd80f76ae4d4cb6b7f58526e688ff23abb522 Mon Sep 17 00:00:00 2001 From: Hary Ayala Date: Sat, 11 Apr 2020 01:34:35 -0600 Subject: [PATCH] Adding mDNS ability to the webserver to avoid looking for the ip --- esp8266-nanoleaf-webserver.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/esp8266-nanoleaf-webserver.ino b/esp8266-nanoleaf-webserver.ino index b79f626..b0e28a7 100644 --- a/esp8266-nanoleaf-webserver.ino +++ b/esp8266-nanoleaf-webserver.ino @@ -28,7 +28,7 @@ extern "C" { #include #include "GradientPalettes.h" #include "Field.h" - +#include //Enable mDNS availability /*######################## MAIN CONFIG ########################*/ @@ -616,6 +616,7 @@ void broadcastString(String name, String value) } void loop() { + MDNS.update(); // Add entropy to random number generator; we use a lot of it. random16_add_entropy(random(65535)); @@ -645,7 +646,13 @@ void loop() { hasConnected = true; Serial.print("Connected! Open http://"); Serial.print(WiFi.localIP()); - Serial.println(" in your browser"); + Serial.println(" in your browser \n"); + if (!MDNS.begin(HOSTNAME)) { + Serial.println("Error setting up MDNS responder! \n"); + } else { + Serial.println("mDNS responder started \n"); + MDNS.addService("http", "tcp", 80); + } } }