Skip to content

ESP32S2: Static IP and DHCP stop fixes #4103

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 1 commit into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);

log_v("Configuring %s static IP: " IPSTR ", MASK: " IPSTR ", GW: " IPSTR,
interface == ESP_IF_WIFI_STA ? "Station" :
interface == ESP_IF_WIFI_AP ? "SoftAP" : "Ethernet",
IP2STR(&info.ip), IP2STR(&info.netmask), IP2STR(&info.gw));

esp_err_t err = ESP_OK;
if(interface != ESP_IF_WIFI_AP){
err = esp_netif_dhcpc_get_status(esp_netif, &status);
Expand All @@ -99,7 +104,7 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA
return err;
}
err = esp_netif_dhcpc_stop(esp_netif);
if(err){
if(err && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED){
log_e("DHCPC Stop Failed! 0x%04x", err);
return err;
}
Expand All @@ -122,7 +127,7 @@ esp_err_t set_esp_interface_ip(esp_interface_t interface, IPAddress local_ip=IPA
return err;
}
err = esp_netif_dhcps_stop(esp_netif);
if(err){
if(err && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED){
log_e("DHCPS Stop Failed! 0x%04x", err);
return err;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
if(err == ESP_OK){
err = set_esp_interface_dns(ESP_IF_WIFI_STA, dns1, dns2);
}
_useStaticIp = err == ESP_OK;
return err == ESP_OK;
}

Expand Down