← index #10957PR #17057
Related · medium · value 5.309
QUERY · ISSUE

RP2040: mDNS support in AP mode

openby ThinkTransitopened 2023-03-07updated 2023-03-07
enhancement

Implement mdns in AP mode on RP2 port to allow users to access micropython device by hostname.

CANDIDATE · PULL REQUEST

ports/rp2: Fix rp2 mDNS issue via new cyw43 driver hooks.

mergedby mseminatoreopened 2025-03-31updated 2025-04-24
port-rp2

Summary

As a number of users have reported via issues and discussions, the RP2 port of MicroPython has an incomplete mDNS implementation. The code in main.c calls mdns_resp_init() which opens the UDP socket for mDNS. However, no code in the cyw43 driver of the RP2 port makes the proper calls to mdns_resp_add_netif() and mdns_resp_remove_netif() to send the announce packets. The wiznet5k driver does make these calls and was used as a model for these changes.

This PR attempts to address this by very small changes to the ports/rp2/cyw43_configport.h file.

As far as I can tell this driver is currently used only by the RP2 port.

The change uses new cyw43 driver hooks to map via driver macros CYW43_CB_TCPIP_INIT_EXTRA and CYW43_CB_TCPIP_DEINIT_EXTRA to the appropriate LWIP MDNS calls.

Testing

This was tested by building the firmware and deploying to a PicoW, starting a WLAN connection and pinging PicoW.local from several devices on the local network. I also tested changing the hostname from the default.

Trade-offs and Alternatives

Alternatively, if this PR is not accepted we should disable the partial implementation by setting LWIP_MDNS_RESPONDER to 0 in lwipopts.h so that users can implement their own mDNS solutions without E_ADDRINUSE failures. A user should not have to build their own firmware to disable a partial/broken mDNS solution.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied