Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ethernet support - could this help get mDNS to work? #833

Open
DP365 opened this issue Apr 9, 2024 · 1 comment
Open

Ethernet support - could this help get mDNS to work? #833

DP365 opened this issue Apr 9, 2024 · 1 comment

Comments

@DP365
Copy link

DP365 commented Apr 9, 2024

I saw in the FAQ and some comments that mDNS issues currently prevent HomeSpan from supporting Ethernet. Could the following help get this implemented? I don't have the deep knowledge required to give this a try....

From: https://www.reddit.com/r/esp32/comments/vwegz5/comment/jd70zrd/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

I found I had some time last night to investigate and I have mDNS working with w5500 spi ethernet on esp-idf 4.4.4.

I looked in the mdns source code (components/mdns/mdns.c) and I can see that mDNS is enabled in only 3 situations.

You have DHCP Client Enabled and you get assign an IP address.
You have had DHCP Client Enabled, and its been stopped before the event ETHERNET_EVENT_CONNECTED is fired.
You mdns_init() after the Ethernet interface is already connected.
In my situation I started mdns_init() first (as the examples and documentation suggest you should) and then started the ethernet interface with a static IP address and DHCP Server enabled. This meant that when ETHERNET_EVENT_CONNECTED fired, the mdns code checked if if the DHCP Client had been stopped (this check errors out if the DHCP Server is running) so it never started mdns on the interface.

Interestingly enough if you had a static IP and were not running the DHCP Server (i.e you initialise the interface without DHCP Client and go directly to the static IP as opposed to the default of turning DHPC Client off and assigning an IP) this would also fail as the DHCP Client Check would not be ESP_NETIF_DHCP_STOPPED but ESP_NETIF_DHCP_INIT.

There are 2 solutions to this:-

Patch the mdns.c code to handle the condition of ETHERNET_EVENT_CONNECTED with DHCP Server running. I initially did this as a test and all was good.
Don't mdns_init() until after Ethernet is already connected. This is an easier method as it does not require any patching to the mdns code. I took my patch out and just did this, as it works fine for my situation where the ethernet will always be running, always connected and that will never change.

@HomeSpan
Copy link
Owner

Thanks for the info -- fortunately I've been able to resolve the issue (see #738). Problem was my use of the Arduino Ethernet driver libraries. The ESP libraries do not seem to have the MDNS issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants