mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 19:44:08 +00:00
[wifi] Start IPv6 link-local on connect, not on DHCPv4 lease (#19749)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
co-authored by
Claude Opus 5.5
J. Nick Koston
parent
5328e5f5e0
commit
25eaf1d025
@@ -829,6 +829,12 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
|
||||
(const char *) it.ssid, bssid_buf, it.channel, get_auth_mode_str(it.authmode));
|
||||
#endif
|
||||
s_sta_connected = true;
|
||||
#if USE_NETWORK_IPV6
|
||||
// Start SLAAC on association, not after a DHCPv4 lease that may never arrive.
|
||||
if (esp_err_t ll_err = esp_netif_create_ip6_linklocal(s_sta_netif); ll_err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "esp_netif_create_ip6_linklocal failed: %s", esp_err_to_name(ll_err));
|
||||
}
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
if (this->state_ == WIFI_COMPONENT_STATE_STA_CONNECTED) {
|
||||
// Driver-initiated roam: the WIFI_REASON_ROAMING disconnect was ignored,
|
||||
// so the state machine never left STA_CONNECTED.
|
||||
@@ -881,9 +887,6 @@ void WiFiComponent::wifi_process_event_(IDFWiFiEvent *data) {
|
||||
|
||||
} else if (data->event_base == IP_EVENT && data->event_id == IP_EVENT_STA_GOT_IP) {
|
||||
const auto &it = data->data.ip_got_ip;
|
||||
#if USE_NETWORK_IPV6
|
||||
esp_netif_create_ip6_linklocal(s_sta_netif);
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
ESP_LOGV(TAG, "static_ip=" IPSTR " gateway=" IPSTR, IP2STR(&it.ip_info.ip), IP2STR(&it.ip_info.gw));
|
||||
this->got_ipv4_address_ = true;
|
||||
#ifdef USE_WIFI_IP_STATE_LISTENERS
|
||||
|
||||
Reference in New Issue
Block a user