Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down