Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit e80d12b

Browse files
authored
Merge pull request #1 from skezo/mdns
fix(#15) add bool to stop calling MDNS.begin on device call
2 parents d50fd30 + 70e38e2 commit e80d12b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/esp8266-google-home-notifier.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ boolean GoogleHomeNotifier::device(const char *name, const char *locale, int to)
1717

1818
if (strcmp(this->m_name, name) != 0) {
1919
int i = 0;
20-
if (!MDNS.begin(hostString)) {
21-
this->setLastError("Failed to set up MDNS responder.");
22-
return false;
20+
if (!this->m_mDNSIsRunning) {
21+
if (!MDNS.begin(hostString)) {
22+
this->setLastError("Failed to set up MDNS responder.");
23+
return false;
24+
}
25+
this->m_mDNSIsRunning = true;
2326
}
2427
do {
2528
n = MDNS.queryService("googlecast", "tcp");

src/esp8266-google-home-notifier.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef class GoogleHomeNotifier {
4949
char m_locale[10] = "en";
5050
char m_name[128] = "";
5151
char m_lastError[128] = "";
52+
bool m_mDNSIsRunning = false;
5253
static bool encode_string(pb_ostream_t *stream, const pb_field_t *field, void * const *arg);
5354
static bool decode_string(pb_istream_t *stream, const pb_field_t *field, void **arg);
5455
boolean connect();

0 commit comments

Comments
 (0)