From 29339aee3ce89dcfd7c86eb5a1403a1a865f7de6 Mon Sep 17 00:00:00 2001 From: luc lebosse Date: Tue, 21 Apr 2015 11:19:29 +0800 Subject: [PATCH] Add Compilation Condition for mDNS Add Compilation Condition for mDNS as not mandatory --- esp8266/esp8266.ino | 4 ++++ esp8266/wifi.cpp | 4 ++++ esp8266/wifi.h | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/esp8266/esp8266.ino b/esp8266/esp8266.ino index e9b3913c..7e38f3ca 100644 --- a/esp8266/esp8266.ino +++ b/esp8266/esp8266.ino @@ -37,7 +37,9 @@ #include #include #include +#if MDNS_FEATURE #include +#endif extern "C" { #include "user_interface.h" } @@ -83,8 +85,10 @@ void setup() { //main loop void loop() { +#if MDNS_FEATURE // Check for any mDNS queries and send responses wifi_config.mdns.update(); +#endif //web requests web_interface.WebServer.handleClient(); //TODO use a method to handle serial also in class and call it instead of this one diff --git a/esp8266/wifi.cpp b/esp8266/wifi.cpp index 1496b456..7d095319 100644 --- a/esp8266/wifi.cpp +++ b/esp8266/wifi.cpp @@ -22,7 +22,9 @@ #include "config.h" #include "ESP8266WiFi.h" #include "IPAddress.h" +#if MDNS_FEATURE #include +#endif extern "C" { #include "user_interface.h" } @@ -132,6 +134,7 @@ bool WIFI_CONFIG::Setup() if (wifi_get_opmode()==WIFI_AP || wifi_get_opmode()==WIFI_AP_STA) configAP( local_ip, gateway, subnet); else WiFi.config( local_ip, gateway, subnet); } + #if MDNS_FEATURE //Get IP if (wifi_get_opmode()==WIFI_STA)currentIP=WiFi.localIP(); else currentIP=WiFi.softAPIP(); @@ -144,6 +147,7 @@ bool WIFI_CONFIG::Setup() if (!mdns.begin("esp8266", currentIP)) { Serial.println("Error setting up MDNS responder!"); } + #endif return true; } diff --git a/esp8266/wifi.h b/esp8266/wifi.h index 5c984600..cca8f09a 100644 --- a/esp8266/wifi.h +++ b/esp8266/wifi.h @@ -21,15 +21,20 @@ #ifndef WIFI_h #define WIFI_h #include +#include "config.h" #include "IPAddress.h" #include +#if MDNS_FEATURE #include +#endif class WIFI_CONFIG { public: // multicast DNS responder feature + #if MDNS_FEATURE MDNSResponder mdns; + #endif bool Setup(); char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]); char * ip2str(IPAddress Ip );