BREAKING: mDNS: use STA as default interface #7042
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Edit by @devyte:
The old behavior is as follows:
-In STA mode, MDNS works on the STA interface
-In AP mode, MDNS works on the AP interface
-In AP+STA mode, MDNS works on the AP interface and not on the STA interface
This sounds reasonable, but it causes all sorts of confusion (and opened issues and comments) when switching WiFi mode on the fly. In particular, when in STA mode, the responder works when accessing from another device on the network, but when switching to AP+STA mode, the ESP suddenly disappears, because MDNS switches to the AP interface.
Obviously, in order to achieve the old behavior, there is a lot of complexity inside MDNS to handle the mode changes.
After several and repeated internal discussions, it has been decided to simplify this to WYSIWYG. The standard MDNS instance works on the STA interface, period. If the STA interface is up, it responds. If the STA interface is down, MDNS is shut down. If the user wants AP mode, or responses on the AP interface in AP+STA mode, then a separate secondary MDNS instance needs to be declared and tied to the AP interface. That secondary instance also needs to have its ::update() method called in the loop.
The same will be true in the future with other interfaces, such as the lwip-integrated Ethernet.
This PR ties the standard MDNS to the STA interface, and leaves the AP interface without a MDNS responder by default.
Edit by d-a-v:
fixes #6975