1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 08:12:22 +01:00

Enable IPv6 for ESP8266 and Raspberry pi pico w (RP2040) (#4759)

This commit is contained in:
Jimmy Hedman
2023-09-12 22:05:02 +02:00
committed by GitHub
parent fc354eec0e
commit dadbc1aefa
9 changed files with 41 additions and 34 deletions

View File

@@ -19,6 +19,7 @@ extern "C" {
#include "lwip/apps/sntp.h"
#if LWIP_IPV6
#include "lwip/netif.h" // struct netif
#include <AddrList.h>
#endif
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
#include "LwipDhcpServer.h"
@@ -164,11 +165,11 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
ip_addr_t dns;
if (uint32_t(manual_ip->dns1) != 0) {
dns.addr = static_cast<uint32_t>(manual_ip->dns1);
ip_addr_set_ip4_u32_val(dns, static_cast<uint32_t>(manual_ip->dns1));
dns_setserver(0, &dns);
}
if (uint32_t(manual_ip->dns2) != 0) {
dns.addr = static_cast<uint32_t>(manual_ip->dns2);
ip_addr_set_ip4_u32_val(dns, static_cast<uint32_t>(manual_ip->dns2));
dns_setserver(1, &dns);
}
@@ -325,6 +326,18 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
return false;
}
#if ENABLE_IPV6
for (bool configured = false; !configured;) {
for (auto addr : addrList) {
ESP_LOGV(TAG, "Address %s", addr.toString().c_str());
if ((configured = !addr.isLocal() && addr.isV6())) {
break;
}
}
delay(500); // NOLINT
}
#endif
if (ap.get_channel().has_value()) {
ret = wifi_set_channel(*ap.get_channel());
if (!ret) {