mDNS in OpenThread

mariar
Posts: 7
Joined: Wed Sep 20, 2023 2:07 pm

mDNS in OpenThread

Postby mariar » Thu Oct 19, 2023 2:28 pm

Hello,
I have two ESP32-H2 working on thread protocol, one as a leader and the other one as router and the communication used between them is CoAP. I am using static IP address on both devices and the CoAP communication is going through those IP addresses.
Now i want to send and receive data using mDNS instead of IP addresses.
I tried this method :

#define EXAMPLE_MDNS_INSTANCE "Thread-mDNS"

void launch_mdns(void)
{
// Initialize mDNS
ESP_ERROR_CHECK( mdns_init() );
// Set mDNS hostname (required if you want to advertise services)
ESP_ERROR_CHECK( mdns_hostname_set("Thread-Leader") );
// Set default mDNS instance name
ESP_ERROR_CHECK( mdns_instance_name_set(EXAMPLE_MDNS_INSTANCE) );
// Advertise the device UID as an mDNS service with the name "Thread Leader"
ESP_ERROR_CHECK(mdns_service_add("Thread-Leader", "_coap", "_udp", 5683, NULL, 0));
}

I've launched mDNS function from the server , and from the client part, i resolved it as follow :

ip6_addr_t resolved_ip6;
mdns_query_aaaa("Thread-Leader" , 2000 , &resolved_ip6);
const char *server_ip_address = ip6addr_ntoa(&resolved_ip6);

at the client output, i obtained this message after error handling the query :
coap client: mDNS query failed

Can anyone help me how to do it?

Who is online

Users browsing this forum: Bing [Bot] and 139 guests