summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Seminatore <nebula_peeps4t@icloud.com>2025-03-31 11:38:36 -0700
committerDamien George <damien@micropython.org>2025-04-03 13:17:14 +1100
commitf96417dbf28617c533e4f2e65c65d1ed11f089fa (patch)
treedb7ae8cb2ec934895bcb05279c79f9ba77ae1e19
parent5eee5a67dc69f6b701e9a79b6fd1e047dfbd55a9 (diff)
rp2/cyw43_configport: Fix cyw43 mDNS by properly starting mDNS on netif.
The rp2 port 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 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 commit attempts to address this by very small changes to the `ports/rp2/cyw43_configport.h` file. The change uses new cyw43 driver hooks to map the driver macros `CYW43_CB_TCPIP_INIT_EXTRA` and `CYW43_CB_TCPIP_DEINIT_EXTRA` to the appropriate lwIP mDNS calls. Fixes issue #15297. Signed-off-by: Mark Seminatore <nebula_peeps4t@icloud.com>
-rw-r--r--ports/rp2/cyw43_configport.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/ports/rp2/cyw43_configport.h b/ports/rp2/cyw43_configport.h
index ead1a3953..552330574 100644
--- a/ports/rp2/cyw43_configport.h
+++ b/ports/rp2/cyw43_configport.h
@@ -33,6 +33,7 @@
#include "py/mphal.h"
#include "py/runtime.h"
#include "extmod/modnetwork.h"
+#include "lwip/apps/mdns.h"
#include "pendsv.h"
#define CYW43_INCLUDE_LEGACY_F1_OVERFLOW_WORKAROUND_VARIABLES (1)
@@ -167,4 +168,19 @@ static inline void cyw43_delay_ms(uint32_t ms) {
#define CYW43_EVENT_POLL_HOOK mp_event_handle_nowait()
+#if LWIP_MDNS_RESPONDER == 1
+
+// Hook for any additional TCP/IP initialization than needs to be done.
+// Called after the netif specified by `itf` has been set up.
+#ifndef CYW43_CB_TCPIP_INIT_EXTRA
+#define CYW43_CB_TCPIP_INIT_EXTRA(self, itf) mdns_resp_add_netif(&self->netif[itf], mod_network_hostname_data)
+#endif
+
+// Hook for any additional TCP/IP deinitialization than needs to be done.
+// Called before the netif specified by `itf` is removed.
+#ifndef CYW43_CB_TCPIP_DEINIT_EXTRA
+#define CYW43_CB_TCPIP_DEINIT_EXTRA(self, itf) mdns_resp_remove_netif(&self->netif[itf])
+#endif
+
+#endif
#endif // MICROPY_INCLUDED_RP2_CYW43_CONFIGPORT_H