Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix switching to static address with lwip2
For some reason, ip address is not propagated in a visible way for lwip2
when switching to static address (wifi.config()) *after* wifi.begin().

This patch calls lwip-v1.4's netif_set_addr() with the new ip address to set
all things up, just like it is done and right when wifi.begin() is called
after wifi.config().

Also tested when IPv6 is enabled.

fixes #5839
fixes #6024
  • Loading branch information
d-a-v committed Apr 30, 2019
commit eed76e2e5af406336111e599b607940c0f317592
12 changes: 12 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ wl_status_t ESP8266WiFiSTAClass::begin() {
* @param dns1 Static DNS server 1
* @param dns2 Static DNS server 2
*/

#if LWIP_VERSION_MAJOR != 1
#undef netif_set_addr // need to call lwip-v1.4 netif_set_addr()
extern "C" struct netif* eagle_lwip_getif (int netif_index);
extern "C" void netif_set_addr (struct netif* netif, ip4_addr_t* ip, ip4_addr_t* netmask, ip4_addr_t* gw);
#endif

bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress arg2, IPAddress arg3, IPAddress dns2) {

if(!WiFi.enableSTA(true)) {
Expand Down Expand Up @@ -310,6 +317,11 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress a
dns_setserver(1, dns2);
}

#if LWIP_VERSION_MAJOR != 1
// trigger address change by calling lwip-v1.4 api
netif_set_addr(eagle_lwip_getif(STATION_IF), &info.ip, &info.netmask, &info.gw);
#endif

return true;
}

Expand Down