BREAKING: mDNS: use STA as default interface by d-a-v · Pull Request #7042 · esp8266/Arduino (original) (raw)
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