Closed CelliesProjects closed 6 years ago
Fixed my issue with CelliesProjects/aquacontrol32@25d6f2097966ee96787db8ec0374e43f610e3a6d The statement
esp_err_t err = mdns_init();
Was the actual problem, it should include arguments referring to the WiFi interface. But the following code did the trick:
if ( !MDNS.begin( "" ) )
{
ESP_LOGE( TAG, "Error setting up mDNS." );
}
else if ( !setupMDNS( hostName ) )
{
ESP_LOGE( TAG, "Error setting up %s as hostname. ", hostName );
}
tl;dr: Just start MDNS with an empty hostname.
Hardware:
Board: MH ET LIVE d1 mini ESP32 Core Installation/update date: 30 march 2018 3a4ec66d41615cbb1c3e830cb6e761cdc4cca9d3 IDE name: Arduino IDE Flash Frequency: 80Mhz Upload Speed: 115200
Description:
Afaik it is impossible to start the mDNS service without assigning a name at the same time. Something like
MDNS.begin("ESP32_Browser")
will assign a name directly.But I would like to query if a avahi hostname is already on my network before I assign it to a device.
This mDNS test code (adapted from https://github.com/espressif/esp-idf/blob/master/docs/en/api-reference/protocols/mdns.rst ) will cause an error and reboot the esp32. The crash is triggered by the
esp_err_t err = mdns_query_a(host_name, 2000, &addr)
statement. According to the exception decoder, an error is thrown from within the mDNS component.So scanning for existing hostname ( without assigning one ) is impossible in Arduino IDE?
Sketch:
Debug Messages:
Exception decoded: