mdns disappears after a few minutes

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

mdns disappears after a few minutes

Postby sorenhl » Wed Jun 27, 2018 6:44 pm

Hi,

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);
The device keeps running as intended and the tcp server, gpio and such works as intended.

Any idea why this could be or how I can debug this?

sorenhl
Posts: 22
Joined: Sun Jun 03, 2018 9:34 pm

Re: mdns disappears after a few minutes

Postby sorenhl » Fri Jun 29, 2018 12:18 pm

If anybody have a code example of something that they have successfully tested stable, I would love to try that out on my device.

Who is online

Users browsing this forum: No registered users and 132 guests