From e9e12f72dfb3e80b8d8fd08461ccbd3b655ba6e7 Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Sat, 16 Feb 2019 08:53:05 +0100 Subject: [PATCH] Fix hardcoded dependency of ArduinoOTA on mDNS Fixes #4643 This is especially important when compiling for host mode, because ArduinoOTA is pulled in unconditionally by the Makefile in tests/host. Thus it breaks the build as soon as NO_GLOBAL_INSTANCES or NO_GLOBAL_MDNS is defined. --- libraries/ArduinoOTA/ArduinoOTA.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/ArduinoOTA/ArduinoOTA.cpp b/libraries/ArduinoOTA/ArduinoOTA.cpp index e2125732be..ea619d4562 100644 --- a/libraries/ArduinoOTA/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/ArduinoOTA.cpp @@ -19,8 +19,10 @@ extern "C" { #include "lwip/igmp.h" #include "lwip/mem.h" #include "include/UdpContext.h" -#include +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) +#include +#endif #ifdef DEBUG_ESP_OTA #ifdef DEBUG_ESP_PORT @@ -130,7 +132,8 @@ void ArduinoOTAClass::begin(bool useMDNS) { if(!_udp_ota->listen(IP_ADDR_ANY, _port)) return; _udp_ota->onRx(std::bind(&ArduinoOTAClass::_onRx, this)); - + +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) if(_useMDNS) { MDNS.begin(_hostname.c_str()); @@ -140,6 +143,7 @@ void ArduinoOTAClass::begin(bool useMDNS) { MDNS.enableArduino(_port); } } +#endif _initialized = true; _state = OTA_IDLE; #ifdef OTA_DEBUG @@ -361,8 +365,10 @@ void ArduinoOTAClass::handle() { _state = OTA_IDLE; } +#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS) if(_useMDNS) MDNS.update(); //handle MDNS update as well, given that ArduinoOTA relies on it anyways +#endif } int ArduinoOTAClass::getCommand() {