Page 1 of 1

mDNS not found on ESP IDF 5.1.2

Posted: Fri Jan 05, 2024 10:36 am
by tankist
I make a WiFi device on ESP32-S3, it should works on STA mode and connects to another access point (AP). AP has DHCP server so when my device is connected to AP is has random IP address. There is an application on AP which should communicate with TCP server on my device, it doesn't know current IP address of my device. So I decided to use DNS server on ESP side to make connection easy: AP application will be connected to TCP server on ESP by host name, not by IP address.

I wonder if it possible to start DNS server on ESP in STA mode. I found out some information about mDNS server. I tried to use the example:

Code: Select all

	    ESP_ERROR_CHECK(mdns_init());
	    ESP_ERROR_CHECK(mdns_hostname_set("name"));
but is was unsuccessful: functions mdns_init() and mdns_hostname_set() not found.
I tried to search in ESP-IDF directory to find the right location of this function, but... I didn't find them at all! There are no files inside ESP-IDF directory which contains these functions. They are called in examples only.

So there is a question: where can I find these finctions?

I use official Espressif-IDE 2.11.1 with ESP-IDF 5.1.2, windows platform.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Fri Jan 05, 2024 2:02 pm
by MicroController
https://docs.espressif.com/projects/esp ... /mdns.html:
The ESP-IDF component mDNS has been moved from ESP-IDF since version v5.0 to a separate repository.
...
To add mDNS component in your project, please run idf.py add-dependency espressif/mdns.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Mon Jan 08, 2024 5:36 am
by tankist
Thank you for the suggestion, but the only thing this command does is just update the content of idf_component.yml file. The requested component still doesn't appear in ESP-IDF directory. Does this require any additional steps?

Re: mDNS not found on ESP IDF 5.1.2

Posted: Mon Jan 08, 2024 9:50 am
by Pixellord
You can find an example of mDNS in RESTful server:
https://github.com/espressif/esp-idf/bl ... est_main.c

Re: mDNS not found on ESP IDF 5.1.2

Posted: Tue Jan 09, 2024 5:36 am
by tankist
Pixellord wrote:
Mon Jan 08, 2024 9:50 am
You can find an example of mDNS in RESTful server:
https://github.com/espressif/esp-idf/bl ... est_main.c
The example you provide is "how to use", but the question is "where to get". I still have no idea how to make DNS server on current version of ESP IDF.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Tue Jan 09, 2024 11:15 am
by MicroController
tankist wrote:
Tue Jan 09, 2024 5:36 am
The example you provide is "how to use", but the question is "where to get". I still have no idea how to make DNS server on current version of ESP IDF.
Have you tried building the example?

(See also: https://docs.espressif.com/projects/esp ... %20project)

Re: mDNS not found on ESP IDF 5.1.2

Posted: Tue Jan 09, 2024 11:07 pm
by mbratch
tankist wrote:
Mon Jan 08, 2024 5:36 am
Thank you for the suggestion, but the only thing this command does is just update the content of idf_component.yml file. The requested component still doesn't appear in ESP-IDF directory. Does this require any additional steps?
Did you try doing the build after creating the `idf_component.yml` file in the location prescribed?
The build tools fetch it automatically when it's specified.

See IDF Component Manager:
The IDF Component Manager is a tool that downloads dependencies for any ESP-IDF CMake project. The download happens automatically during a run of CMake. It can source components either from the component registry or from a Git repository.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Wed Jan 10, 2024 8:46 am
by tankist
MicroController wrote:
Tue Jan 09, 2024 11:15 am
tankist wrote:
Tue Jan 09, 2024 5:36 am
The example you provide is "how to use", but the question is "where to get". I still have no idea how to make DNS server on current version of ESP IDF.
Have you tried building the example?

(See also: https://docs.espressif.com/projects/esp ... %20project)
I haven't build any example before so I tried to do this as suggested. It was helpful, because I found out that mDNS componet downloads automatically into a project folder, not into ESP-IDF as I expected. I tried to repeat these steps to add a component to my project and I got a tutorial how to do this:
1) Open shell (in my case Windows Power Shell) and navigate into a project directory
2) Execute idf.py add-dependency espressif/mdns command
3) Execute idf.py reconfigure command (no one tell me I should do that)
4) Rebuild a project inside ESP IDE

After third step I've got a directory with a new component inside.

I guess it's kind of ridiculous to do so many steps in shell. I wonder if it possible to do the same via ESP IDE graphical interface.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Wed Jan 10, 2024 8:48 am
by tankist
mbratch wrote:
Tue Jan 09, 2024 11:07 pm
tankist wrote:
Mon Jan 08, 2024 5:36 am
Thank you for the suggestion, but the only thing this command does is just update the content of idf_component.yml file. The requested component still doesn't appear in ESP-IDF directory. Does this require any additional steps?
Did you try doing the build after creating the `idf_component.yml` file in the location prescribed?
The build tools fetch it automatically when it's specified.

See IDF Component Manager:
The IDF Component Manager is a tool that downloads dependencies for any ESP-IDF CMake project. The download happens automatically during a run of CMake. It can source components either from the component registry or from a Git repository.
The build process DOES NOT help download a component. This only happens after idf.py reconfigure command.

Re: mDNS not found on ESP IDF 5.1.2

Posted: Wed Jan 10, 2024 4:53 pm
by mbratch
tankist wrote:
Wed Jan 10, 2024 8:48 am
The build process DOES NOT help download a component. This only happens after idf.py reconfigure command.
Yes, I think that is described in the details of the link I provided. The reconfiguration is needed for the process to work.

It would indeed be nice to have access to all these things from the IDE. I use Eclipse and, only fairly recently, the "idf.py fullclean" was available from within the IDE as a right-click command on the project.