1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

lwip2: (re)fix setting static ip address (#6194)

This commit is contained in:
david gauchard 2019-06-17 23:57:31 +02:00 committed by GitHub
parent 9f03bbb8c3
commit 59db907647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,6 +309,13 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
return false;
}
#if LWIP_VERSION_MAJOR != 1 && !CORE_MOCK
// get current->previous IP address
// (check below)
struct ip_info previp;
wifi_get_ip_info(STATION_IF, &previp);
#endif
struct ip_info info;
info.ip.addr = local_ip.v4();
info.gw.addr = gateway.v4();
@ -334,7 +341,9 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
#if LWIP_VERSION_MAJOR != 1 && !CORE_MOCK
// trigger address change by calling lwIP-v1.4 api
// (see explanation above)
netif_set_addr(eagle_lwip_getif(STATION_IF), &info.ip, &info.netmask, &info.gw);
// only when ip is already set by other mean (generally dhcp)
if (previp.ip.addr != 0 && previp.ip.addr != info.ip.addr)
netif_set_addr(eagle_lwip_getif(STATION_IF), &info.ip, &info.netmask, &info.gw);
#endif
return true;