Skip to content

nopnop2002/esp-idf-mdns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-idf-mdns

How to name resolution by mDNS.

Since ESP-IDF Ver5, mDNS has been moved from built-in library to this IDF component registry.
Accordingly, the mDNS official example has been removed from the ESP-IDF repository.
The official repository for mDNS is here.

The official repository comes with example code, but it's a bit confusing.
There are two methods for name resolution using mDNS.

  • Name resolution by host name
  • Name resolution by service name

This is a quick example of each.

Software requiment

ESP-IDF V4.4/V5.x.
ESP-IDF V5.0 is required when using ESP32-C2.
ESP-IDF V5.1 is required when using ESP32-C6.

Hardware requirements

Requires two ESP32s.

Name resolution by host name

To find the IP address, you need to know the mDNS hostname.
mDNS hostnames must be unique.
Write query-host1 to ESP32#1 and query-host2 to ESP32#2.
mDNS hostname for ESP32#1 is esp32-mdns1.local.
mDNS hostname for ESP32#2 is esp32-mdns2.local.

ESP32#1

Look for esp32-mdns2.local.

git clone https://github.com/nopnop2002/esp-idf-mdns
cd esp-idf-mdns/query-host1
idf.py menuconfig
idf.py flash

ESP32#2

Look for esp32-mdns1.local.

cd esp-idf-mdns/query-host2
idf.py menuconfig
idf.py flash

Configuration

config-top config-app-host

Screen shot

screen-host

Name resolution by service name

To find the IP address, you need to know the service name.
Duplicate service names are allowed.
If you give two nodes the same service name, they can find each other.
This is useful when doing P2P communication with UDP.
Write query-service to ESP32#1 and ESP32#2.
Each mDNS hostname is generated from MAC address.
Therefore, the other party's mDNS host name is completely unknown.

ESP32#1

Look for the service name of _service_49876.

git clone https://github.com/nopnop2002/esp-idf-mdns
cd esp-idf-mdns/query-service
idf.py menuconfig
idf.py flash

ESP32#2

Look for the service name of _service_49876.

cd esp-idf-mdns/query-service
idf.py menuconfig
idf.py flash

Configuration

config-top config-app-service

Screen shot

screen-service

Releases

No releases published

Packages

No packages published