8000 wiznet: Reset mDNS when interface is brought up. · micropython/micropython@e3a68f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e3a68f9

Browse files
committed
wiznet: Reset mDNS when interface is brought up.
The LwIP interface is removed in wiznet5k_deinit() which is called as part of the init sequence. Therefore, if using mDNS, then the interface will need to be re-added when bringing the interface up. Additionally, this allows to set the hostname from Micropython code prior to bringing the interface up and mDNS responding to the (new) hostname. This allows the hostname to be configured and saved on the flash or be based on dynamic information such as the MAC or unique_id(). [1] "Multicast DNS for lwIP" https://github.com/lwip-tcpip/lwip/blob/master/doc/mdns.txt Signed-off-by: Jared Hancock <jared.hancock@centeredsolutions.com>
1 parent 82e69df commit e3a68f9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

extmod/network_wiznet5k.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "shared/netutils/netutils.h"
5959
#include "lib/wiznet5k/Ethernet/wizchip_conf.h"
6060
#include "lib/wiznet5k/Ethernet/socket.h"
61+
#include "lwip/apps/mdns.h"
6162
#include "lwip/err.h"
6263
#include "lwip/dns.h"
6364
#include "lwip/dhcp.h"
@@ -334,6 +335,12 @@ static void wiznet5k_lwip_init(wiznet5k_obj_t *self) {
334335
self->netif.flags |= NETIF_FLAG_UP;
335336
dhcp_start(&self->netif);
336337
self->netif.flags &= ~NETIF_FLAG_UP;
338+
339+
#if LWIP_MDNS_RESPONDER
340+
// NOTE: interface is removed in ::wiznet5k_deinit(), which is called as
341+
// part of the init sequence.
342+
mdns_resp_add_netif(&self->netif, mod_network_hostname_data);
343+
#endif
337344
}
338345

339346
void wiznet5k_poll(void) {

0 commit comments

Comments
 (0)
0