mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'fix/esp_netif_reassign_static_ip' into 'master'
fix(esp_netif): Fix reasigning static IP after netif down -> up Closes IDF-13024 and WIFIBUG-1228 See merge request espressif/esp-idf!39725
This commit is contained in:
@@ -1470,11 +1470,12 @@ static void esp_netif_internal_dhcpc_cb(struct netif *netif)
|
||||
} else {
|
||||
if (!ip4_addr_cmp(&ip_info->ip, IP4_ADDR_ANY4)) {
|
||||
esp_netif_start_ip_lost_timer(esp_netif);
|
||||
// synchronize lwip netif with esp_netif setting ip_info to 0,
|
||||
// so the next time we get a valid IP we can raise the event
|
||||
ip4_addr_set(&ip_info->ip, ip_2_ip4(&netif->ip_addr));
|
||||
ip4_addr_set(&ip_info->netmask, ip_2_ip4(&netif->netmask));
|
||||
ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw));
|
||||
if (esp_netif->flags & ESP_NETIF_DHCP_CLIENT && esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) {
|
||||
// Only for active DHCP client (in case of static IP, we keep the last configure value in ip_info)
|
||||
// synchronize lwip netif with esp_netif setting ip_info to 0,
|
||||
// so the next time we get a valid IP we can raise the event
|
||||
esp_netif_reset_ip_info(esp_netif);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1502,7 +1503,10 @@ static void esp_netif_ip_lost_timer(void *arg)
|
||||
esp_netif_update_default_netif(esp_netif, ESP_NETIF_LOST_IP);
|
||||
ESP_LOGD(TAG, "if%p ip lost tmr: raise ip lost event", esp_netif);
|
||||
memset(esp_netif->ip_info_old, 0, sizeof(esp_netif_ip_info_t));
|
||||
memset(esp_netif->ip_info, 0, sizeof(esp_netif_ip_info_t));
|
||||
if (esp_netif->flags & ESP_NETIF_DHCP_CLIENT && esp_netif->dhcpc_status == ESP_NETIF_DHCP_STARTED) {
|
||||
// Reset IP info if using DHCP client (static IP is supposed to be restored based on the ip_info)
|
||||
esp_netif_reset_ip_info(esp_netif);
|
||||
}
|
||||
if (esp_netif->lost_ip_event) {
|
||||
ret = esp_event_post(IP_EVENT, esp_netif->lost_ip_event,
|
||||
&evt, sizeof(evt), 0);
|
||||
|
Reference in New Issue
Block a user