Skip to content

Commit 7be846c

Browse files
authored
Fixes softAPConfig() return (espressif#6294)
1 parent 2c7052a commit 7be846c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

libraries/WiFi/src/WiFiAP.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,23 @@ bool WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress
205205
}
206206

207207
err = set_esp_interface_ip(ESP_IF_WIFI_AP, local_ip, gateway, subnet);
208-
return err == ESP_OK;
208+
209+
// testing effectiveness of the operation beyond internal DHCP Client process
210+
esp_netif_ip_info_t ip;
211+
if(esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_AP), &ip) != ESP_OK){
212+
log_e("Netif Get IP Failed!");
213+
return false;
214+
}
215+
bool ip_ok = IPAddress(ip.ip.addr) == local_ip;
216+
bool gw_ok = IPAddress(ip.gw.addr) == gateway;
217+
bool mk_ok = IPAddress(ip.netmask.addr) == subnet;
218+
219+
if (ip_ok && gw_ok && mk_ok) {
220+
return true;
221+
} else {
222+
log_e("Failed setting: %s %s %s", ip_ok ? "" : "Static IP", gw_ok ? "" : "- Gateway", mk_ok ? "" : "- Netmask");
223+
return false;
224+
}
209225
}
210226

211227

0 commit comments

Comments
 (0)