Skip to content

Commit

Permalink
Fix WiFi STA config IP to INADDR_NONE results in 255.255.255.255
Browse files Browse the repository at this point in the history
Fixes: #4732
  • Loading branch information
me-no-dev committed Feb 3, 2021
1 parent 4b38569 commit 5de03a3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/WiFi/src/WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
}

tcpip_adapter_ip_info_t info;
log_d("STA IP uint32_t: %u.%u.%u.%u\n", local_ip[0], local_ip[1], local_ip[2], local_ip[3]);

if(local_ip != (uint32_t)0x00000000){
if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){
info.ip.addr = static_cast<uint32_t>(local_ip);
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);
Expand Down Expand Up @@ -320,13 +321,13 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne
ip_addr_t d;
d.type = IPADDR_TYPE_V4;

if(dns1 != (uint32_t)0x00000000) {
if(dns1 != (uint32_t)0x00000000 && dns1 != INADDR_NONE) {
// Set DNS1-Server
d.u_addr.ip4.addr = static_cast<uint32_t>(dns1);
dns_setserver(0, &d);
}

if(dns2 != (uint32_t)0x00000000) {
if(dns2 != (uint32_t)0x00000000 && dns2 != INADDR_NONE) {
// Set DNS2-Server
d.u_addr.ip4.addr = static_cast<uint32_t>(dns2);
dns_setserver(1, &d);
Expand Down

0 comments on commit 5de03a3

Please sign in to comment.