Skip to content

Commit e721089

Browse files
everslickdevyte
authored andcommitted
Fix hardcoded dependency of ArduinoOTA on mDNS (#5768)
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.
1 parent 9ba89eb commit e721089

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libraries/ArduinoOTA/ArduinoOTA.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ extern "C" {
1919
#include "lwip/igmp.h"
2020
#include "lwip/mem.h"
2121
#include "include/UdpContext.h"
22-
#include <ESP8266mDNS.h>
2322

23+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
24+
#include <ESP8266mDNS.h>
25+
#endif
2426

2527
#ifdef DEBUG_ESP_OTA
2628
#ifdef DEBUG_ESP_PORT
@@ -130,7 +132,8 @@ void ArduinoOTAClass::begin(bool useMDNS) {
130132
if(!_udp_ota->listen(IP_ADDR_ANY, _port))
131133
return;
132134
_udp_ota->onRx(std::bind(&ArduinoOTAClass::_onRx, this));
133-
135+
136+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
134137
if(_useMDNS) {
135138
MDNS.begin(_hostname.c_str());
136139

@@ -140,6 +143,7 @@ void ArduinoOTAClass::begin(bool useMDNS) {
140143
MDNS.enableArduino(_port);
141144
}
142145
}
146+
#endif
143147
_initialized = true;
144148
_state = OTA_IDLE;
145149
#ifdef OTA_DEBUG
@@ -361,8 +365,10 @@ void ArduinoOTAClass::handle() {
361365
_state = OTA_IDLE;
362366
}
363367

368+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
364369
if(_useMDNS)
365370
MDNS.update(); //handle MDNS update as well, given that ArduinoOTA relies on it anyways
371+
#endif
366372
}
367373

368374
int ArduinoOTAClass::getCommand() {

0 commit comments

Comments
 (0)