Page 1 of 1

mDNS advert

Posted: Tue Aug 27, 2019 4:14 pm
by PeterR
I want to create a number of mDNS adverts.
From a command prompt I monitor for mDNS adverts using:

Code: Select all

dns-sd -B _services._dns-sd._udp
I have copied code the mDNS example codefrom esp\esp-idf\examples\protocols\mdns\main (see bottom).
I wait until I have an Ethernet IP address and then initialise.
I see some broadcasts to 255.255.255.255 from my ESP32's IP address (which is my uDP logger) but no other traffic and dns-sd does not detect the service.

Am I using the correct setup and monitoring commands?

Code: Select all

extern "C" void mdns_initialise()
{
    char* hostname = "petes";
    //initialize mDNS
    ESP_ERROR_CHECK( mdns_init() );
    //set mDNS hostname (required if you want to advertise services)
    ESP_ERROR_CHECK( mdns_hostname_set(hostname) );
    ESP_LOGI(TAG, "mdns hostname set to: [%s]", hostname);
    //set default mDNS instance name
    ESP_ERROR_CHECK( mdns_instance_name_set(EXAMPLE_MDNS_INSTANCE) );
    
    //structure with TXT records
    mdns_txt_item_t serviceTxtData[3] = {
        {"board","esp32"},
        {"u","user"},
        {"p","password"}
    };

    ESP_ERROR_CHECK( mdns_service_add("ESP32-WebServer", "_http", "_tcp", 80, serviceTxtData, 3) );    
}

Re: mDNS advert

Posted: Wed Aug 28, 2019 11:18 am
by PeterR
Failing as going through a gateway (doh!).
Switched to a a switch and can see services now.