From f55387b323a62ad02b1fa9678083bd0e444cf86b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 21 Feb 2026 14:11:19 -0600 Subject: [PATCH] [wifi] Guard lwIP-internal socket registration to LibreTiny only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DHCP/DNS raw UDP PCBs only need tracking on LibreTiny where we directly set MEMP_NUM_UDP_PCB. On ESP32, CONFIG_LWIP_MAX_SOCKETS controls the POSIX socket layer — DHCP/DNS use raw udp_new() bypassing it entirely. Co-Authored-By: Claude Opus 4.6 --- esphome/components/wifi/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/components/wifi/__init__.py b/esphome/components/wifi/__init__.py index a40f04cc45..6edd84e589 100644 --- a/esphome/components/wifi/__init__.py +++ b/esphome/components/wifi/__init__.py @@ -271,7 +271,15 @@ def final_validate(config): def _consume_wifi_sockets(config: ConfigType) -> ConfigType: - """Register UDP PCBs used internally by lwIP for DHCP and DNS.""" + """Register UDP PCBs used internally by lwIP for DHCP and DNS. + + Only needed on LibreTiny where we directly set MEMP_NUM_UDP_PCB (the raw + PCB pool shared by both application sockets and lwIP internals like DHCP/DNS). + On ESP32, CONFIG_LWIP_MAX_SOCKETS only controls the POSIX socket layer — + DHCP/DNS use raw udp_new() which bypasses it entirely. + """ + if not (CORE.is_bk72xx or CORE.is_rtl87xx or CORE.is_ln882x): + return config from esphome.components import socket # lwIP allocates UDP PCBs for DHCP client and DNS resolver internally.