Skip to content

Commit

Permalink
Move mdns timer void to mdns.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Jan 5, 2020
1 parent bdf86bd commit 70aef1b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
11 changes: 1 addition & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,7 @@ void loop() {

// mDNS Reset Timer - Helps avoid the host not found issues
Ticker mDNSTimer;
mDNSTimer.attach(MDNSTIMER, [](){
JsonConfig *config = JsonConfig::getInstance();
MDNS.end();
if (!MDNS.begin(config->hostname)) {
Log.error(F("Error resetting MDNS responder."));
} else {
Log.notice(F("mDNS responder restarted, hostname: %s.local." CR), WiFi.hostname().c_str());
MDNS.addService("http", "tcp", 80);
}
});
mDNSTimer.attach(MDNSTIMER, mdnsreset);

// Reboot timer - I wish controllers could be counted on to be more
// stable but at least it only takes a few seconds.
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ SOFTWARE. */
#include "version.h"
#include "targethandler.h"
#include "bubbles.h"
#include "mdns.h"
#include <WiFiManager.h>
#include <DoubleResetDetect.h>
#include <ESP8266WiFi.h>
Expand Down
11 changes: 11 additions & 0 deletions src/mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ void mdnssetup() {
}
}
}

void mdnsreset() {
JsonConfig *config = JsonConfig::getInstance();
MDNS.end();
if (!MDNS.begin(config->hostname)) {
Log.error(F("Error resetting MDNS responder."));
} else {
Log.notice(F("mDNS responder restarted, hostname: %s.local." CR), WiFi.hostname().c_str());
MDNS.addService("http", "tcp", 80);
}
}
1 change: 1 addition & 0 deletions src/mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ SOFTWARE. */

void mdnssetup();
IPAddress mdnsquery(char hostname[65]);
void mdnsreset();

#endif // _MDNS_H
2 changes: 1 addition & 1 deletion src/ntphandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void NtpHandler::start() {
Serial.print(F("."));
#endif
#endif
_delay(500);
_delay(1000);
single->update();
yield();
}
Expand Down

0 comments on commit 70aef1b

Please sign in to comment.