I am rewriting an esp8266 project and the only functionality left is to make the device discoverable through mDNS.
The issue is, that I can actually discover the device with all the correct information on my phone, but after some minutes it disappears again until I reboot the device. The posts I found about the issue states that I must remember "_" in front of names, but I believe I already covered that part.
I am using Arduino Core as a component, but I decided to try using the esp commands just to be sure that it was not an issue with the Arduino core library.
The following code is run when I receive a SYSTEM_EVENT_STA_GOT_IP wifi event.
Code: Select all
esp_err_t err = mdns_init();
if (err) {
Serial.printf("MDNS Init failed: %d\n", err);
return;
}
String name = "boatcontrol-d1000";
mdns_hostname_set(name.c_str());
mdns_instance_name_set(name.c_str());
mdns_service_add(NULL, "_boatcontrol", "_tcp", 8080, NULL, 0);
mdns_service_instance_name_set("_boatcontrol", "_tcp", name.c_str());
mdns_txt_item_t serviceTxtData[1] = {
{ "version","1.0.0" }
};
mdns_service_txt_set("_boatcontrol", "_tcp", serviceTxtData, 1);
Any idea why this could be or how I can debug this?