Skip to content

Commit f5c4136

Browse files
Add SimpleMDNS, IGMP, and .local lookup (#2582)
* Enable LWIP IGMP, MDNS internal server * Enable MDNS lookup from LWIP DNS * Add SimpleMDNS responder, small code and no malloc * Ensure we copy out lwipopts in make-libpico Adds a small wrapper around the LWIP-provided MDNS responder application. Drop-in replacement in many basic cases for LEAmDNS. For FreeRTOS it is important to not allocate memory on an LWIP callback. LEAmDNS needs to do this to create response objects, leading to crashes. Increase LWIP timers by bumping the LWIP_ARP number (as done before). Replace ArduinoOTA LEAmDNS with SimpleMDNS and update a HTTPUpdateServer example.
1 parent c4b6521 commit f5c4136

39 files changed

+320
-89
lines changed

docs/ota.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Requirements
235235
Implementation Overview
236236
~~~~~~~~~~~~~~~~~~~~~~~
237237

238-
Updates with a web browser are implemented using ``HTTPUpdateServer`` class together with ``WebServer`` and ``LEAmDNS`` classes. The following code is required to get it work:
238+
Updates with a web browser are implemented using ``HTTPUpdateServer`` class together with ``WebServer`` and ``LEAmDNS`` or ``SimpleMDNS`` classes. The following code is required to get it work:
239239

240240
setup()
241241

docs/wifi.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Please note that WiFi on the Pico W is a work-in-progress and there are some imp
4444

4545
* FreeRTOS is supported only on core 0 and from within ``setup`` and ``loop``, not tasks, due to the requirement for a very different LWIP implementation. PRs always appreciated!
4646

47-
* LEAmDNS (``MDNS``) is not supported in FreeRTOS due to internal IRQ-time memory allocations.
47+
* LEAmDNS (``MDNS``) is not supported in FreeRTOS due to internal IRQ-time memory allocations. Instead, use the SimpleMDNS library ( ``#include <SimpleMDNS.h>`` ) which has no such allocations.
4848

4949
The WiFi library borrows much work from the `ESP8266 Arduino Core <https://github.com/esp8266/Arduino>`__ , especially the ``WiFiClient`` and ``WiFiServer`` classes.
5050

include/lwipopts.h

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,57 @@ extern unsigned long __lwip_rand(void);
2121
// Common settings used in most of the pico_w examples
2222
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
2323

24-
#define NO_SYS 1
25-
#define LWIP_SOCKET 0
26-
#define MEM_LIBC_MALLOC 0
24+
#define NO_SYS 1
25+
#define LWIP_SOCKET 0
26+
#define MEM_LIBC_MALLOC 0
2727

28-
#define MEM_ALIGNMENT 4
29-
#define MEM_SIZE (__LWIP_MEMMULT * 16384)
30-
#define MEMP_NUM_TCP_SEG (32)
31-
#define MEMP_NUM_ARP_QUEUE (10)
32-
#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24)
33-
#define LWIP_ARP 2
34-
#define LWIP_ETHERNET 1
35-
#define LWIP_ICMP 1
36-
#define LWIP_RAW 1
37-
#define TCP_WND (8 * TCP_MSS)
38-
#define TCP_MSS 1460
39-
#define TCP_SND_BUF (8 * TCP_MSS)
40-
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
41-
#define LWIP_NETIF_STATUS_CALLBACK 1
42-
#define LWIP_NETIF_LINK_CALLBACK 1
43-
#define LWIP_NETIF_HOSTNAME 1
44-
#define LWIP_NETCONN 0
45-
#define LWIP_STATS 0
46-
#define LWIP_STATS_DISPLAY 0
47-
#define MEM_STATS 0
48-
#define SYS_STATS 0
49-
#define MEMP_STATS 0
50-
#define LINK_STATS 0
51-
#define LWIP_CHKSUM_ALGORITHM 0
52-
#define LWIP_DHCP 1
53-
#define LWIP_IPV4 1
54-
#define LWIP_TCP 1
55-
#define LWIP_UDP 1
56-
#define LWIP_DNS 1
57-
#define LWIP_TCP_KEEPALIVE 1
58-
#define LWIP_NETIF_TX_SINGLE_PBUF 1
59-
#define DHCP_DOES_ARP_CHECK 0
60-
#define LWIP_DHCP_DOES_ACD_CHECK 0
28+
#define MEM_ALIGNMENT 4
29+
#define MEM_SIZE (__LWIP_MEMMULT * 16384)
30+
#define MEMP_NUM_TCP_SEG (32)
31+
#define MEMP_NUM_ARP_QUEUE (10)
32+
//#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + 4)
33+
#define PBUF_POOL_SIZE (__LWIP_MEMMULT > 1 ? 32 : 24)
34+
#define LWIP_ARP 5
35+
#define LWIP_ETHERNET 1
36+
#define LWIP_ICMP 1
37+
#define LWIP_RAW 1
38+
#define TCP_WND (8 * TCP_MSS)
39+
#define TCP_MSS 1460
40+
#define TCP_SND_BUF (8 * TCP_MSS)
41+
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
42+
#define LWIP_NETIF_STATUS_CALLBACK 1
43+
#define LWIP_NETIF_LINK_CALLBACK 1
44+
#define LWIP_NETIF_HOSTNAME 1
45+
#define LWIP_NUM_NETIF_CLIENT_DATA 5
46+
#define LWIP_NETCONN 0
47+
#define LWIP_STATS 0
48+
#define LWIP_STATS_DISPLAY 0
49+
#define MEM_STATS 0
50+
#define SYS_STATS 0
51+
#define MEMP_STATS 0
52+
#define LINK_STATS 0
53+
#define LWIP_CHKSUM_ALGORITHM 0
54+
#define LWIP_DHCP 1
55+
#define LWIP_IPV4 1
56+
#define LWIP_TCP 1
57+
#define LWIP_UDP 1
58+
#define LWIP_DNS 1
59+
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 1
60+
#define LWIP_TCP_KEEPALIVE 1
61+
#define LWIP_NETIF_TX_SINGLE_PBUF 1
62+
#define DHCP_DOES_ARP_CHECK 0
63+
#define LWIP_DHCP_DOES_ACD_CHECK 0
64+
#define LWIP_IGMP 1
65+
#define LWIP_MDNS_RESPONDER 1
66+
#define MDNS_MAX_SERVICES 4
6167

6268
// See #1285
63-
#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 6)
64-
#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5)
69+
#define MEMP_NUM_UDP_PCB (__LWIP_MEMMULT * 7)
70+
#define MEMP_NUM_TCP_PCB (__LWIP_MEMMULT * 5)
6571

6672
#if LWIP_IPV6
67-
#define LWIP_IPV6_DHCP6 1
73+
#define LWIP_IPV6_DHCP6 1
74+
#define LWIP_IPV6_MLD 1
6875
#endif
6976

7077
// NTP

lib/rp2040/libipv4-big.a

194 KB
Binary file not shown.

lib/rp2040/libipv4-bt-big.a

242 KB
Binary file not shown.

lib/rp2040/libipv4-bt.a

242 KB
Binary file not shown.

lib/rp2040/libipv4-ipv6-big.a

216 KB
Binary file not shown.

lib/rp2040/libipv4-ipv6-bt-big.a

264 KB
Binary file not shown.

lib/rp2040/libipv4-ipv6-bt.a

264 KB
Binary file not shown.

lib/rp2040/libipv4-ipv6.a

216 KB
Binary file not shown.

0 commit comments

Comments
 (0)