Skip to content

Remove forced OTA DNS announce #3770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions libraries/ArduinoOTA/ArduinoOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,14 @@ void ArduinoOTAClass::begin() {
if(!_udp_ota->listen(*IP_ADDR_ANY, _port))
return;
_udp_ota->onRx(std::bind(&ArduinoOTAClass::_onRx, this));
MDNS.begin(_hostname.c_str());
if(!MDNS.started()) {
MDNS.begin(_hostname.c_str());

if (_password.length()) {
MDNS.enableArduino(_port, true);
} else {
MDNS.enableArduino(_port);
if (_password.length()) {
MDNS.enableArduino(_port, true);
} else {
MDNS.enableArduino(_port);
}
}
_initialized = true;
_state = OTA_IDLE;
Expand Down Expand Up @@ -253,7 +255,7 @@ void ArduinoOTAClass::_runUpdate() {
if (_error_callback) {
_error_callback(OTA_BEGIN_ERROR);
}

StreamString ss;
Update.printError(ss);
_udp_ota->append("ERR: ", 5);
Expand Down
2 changes: 2 additions & 0 deletions libraries/ESP8266mDNS/ESP8266mDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ bool MDNSResponder::begin(const char* hostname){
_restart();
});

_started = true;

return _listen();
}

Expand Down
13 changes: 9 additions & 4 deletions libraries/ESP8266mDNS/ESP8266mDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ class MDNSResponder {
void addService(String service, String proto, uint16_t port){
addService(service.c_str(), proto.c_str(), port);
}

bool addServiceTxt(char *name, char *proto, char * key, char * value);
bool addServiceTxt(const char *name, const char *proto, const char *key,const char * value){
return addServiceTxt((char *)name, (char *)proto, (char *)key, (char *)value);
}
bool addServiceTxt(String name, String proto, String key, String value){
return addServiceTxt(name.c_str(), proto.c_str(), key.c_str(), value.c_str());
}

int queryService(char *service, char *proto);
int queryService(const char *service, const char *proto){
return queryService((char *)service, (char *)proto);
Expand All @@ -98,7 +98,7 @@ class MDNSResponder {
String hostname(int idx);
IPAddress IP(int idx);
uint16_t port(int idx);

void enableArduino(uint16_t port, bool auth=false);

void setInstanceName(String name);
Expand All @@ -109,6 +109,10 @@ class MDNSResponder {
setInstanceName(String(name));
}

bool started() {
return _started;
}

private:
struct MDNSService * _services;
UdpContext* _conn;
Expand All @@ -120,7 +124,8 @@ class MDNSResponder {
bool _waitingForAnswers;
WiFiEventHandler _disconnectedHandler;
WiFiEventHandler _gotIPHandler;

bool _started = false;


uint16_t _getServicePort(char *service, char *proto);
MDNSTxt * _getServiceTxt(char *name, char *proto);
Expand Down