horihiro / esp8266-google-home-notifier

MIT License
103 stars 23 forks source link

mDNS issues #31

Closed mark8018 closed 3 years ago

mark8018 commented 3 years ago

Hello I had mDNS issues. What is the solution?

C:\Users\0123\Documents\Arduino\libraries\esp8266-google-home-notifier\src\esp8266-google-home-notifier.cpp:36:33: error: 'using MDNSResponder = class esp8266::MDNSImplementation::MDNSResponder' has no member named 'txt' if (strcmp(name, MDNS.txt(i, "fn").c_str()) == 0) { ^ source code

include

include

include

include

include

include

ifndef STASSID

define STASSID "your-ssid"

define STAPSK "your-password"

endif

const char ssid = STASSID; const char password = STAPSK;

GoogleHomeNotifier ghn;

void setup() { Serial.begin(115200); Serial.println("Booting"); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Connection Failed! Rebooting..."); delay(5000); ESP.restart(); }

// Port defaults to 8266 // ArduinoOTA.setPort(8266);

// Hostname defaults to esp8266-[ChipID] // ArduinoOTA.setHostname("myesp8266");

// No authentication by default // ArduinoOTA.setPassword("admin");

// Password can be set with it's md5 value as well // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3 // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");

ArduinoOTA.onStart([]() { String type; if (ArduinoOTA.getCommand() == U_FLASH) { type = "sketch"; } else { // U_FS type = "filesystem"; }

// NOTE: if updating FS this would be the place to unmount FS using FS.end()
Serial.println("Start updating " + type);

}); ArduinoOTA.onEnd([]() { Serial.println("\nEnd"); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { Serial.printf("Progress: %u%%\r", (progress / (total / 100))); }); ArduinoOTA.onError([](ota_error_t error) { Serial.printf("Error[%u]: ", error); if (error == OTA_AUTH_ERROR) { Serial.println("Auth Failed"); } else if (error == OTA_BEGIN_ERROR) { Serial.println("Begin Failed"); } else if (error == OTA_CONNECT_ERROR) { Serial.println("Connect Failed"); } else if (error == OTA_RECEIVE_ERROR) { Serial.println("Receive Failed"); } else if (error == OTA_END_ERROR) { Serial.println("End Failed"); } }); ArduinoOTA.begin(); Serial.println("Ready"); Serial.print("IP address: "); Serial.println(WiFi.localIP());

const char displayName[] = "Family Room";

Serial.println("connecting to Google Home..."); if (ghn.device(displayName, "en") != true) { Serial.println(ghn.getLastError()); return; } Serial.print("found Google Home("); Serial.print(ghn.getIPAddress()); Serial.print(":"); Serial.print(ghn.getPort()); Serial.println(")");

if (ghn.notify("Hello, World!") != true) { Serial.println(ghn.getLastError()); return; } Serial.println("Done."); }

void loop() { ArduinoOTA.handle(); }

horihiro commented 3 years ago

It seems that your project tries to load https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/src/ESP8266mDNS.h , not https://github.com/horihiro/esp8266-google-home-notifier/blob/master/src/ESP8266mDNS.h as MDNS library.

Use the latter.

mark8018 commented 3 years ago

Thank you for your reply! I changed the header of the source code as follows, and the compiler was completed.

include

include

include

include

include