Skip to content

Commit 0788453

Browse files
authored
Merge pull request #219 from JAndrassy/wifi_config_auto
WiFi.config - setting defaults as the Ethernet library
2 parents 2df61b1 + e86ae99 commit 0788453

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/WiFi.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,26 @@ uint8_t WiFiClass::beginEnterprise(const char* ssid, const char* username, const
192192

193193
void WiFiClass::config(IPAddress local_ip)
194194
{
195-
WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
195+
// Assume the DNS server will be the machine on the same network as the local IP
196+
// but with last octet being '1'
197+
IPAddress dns = local_ip;
198+
dns[3] = 1;
199+
config(local_ip, dns);
196200
}
197201

198202
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server)
199203
{
200-
WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
201-
WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
204+
// Assume the gateway will be the machine on the same network as the local IP
205+
// but with last octet being '1'
206+
IPAddress gateway = local_ip;
207+
gateway[3] = 1;
208+
config(local_ip, dns_server, gateway);
202209
}
203210

204211
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
205212
{
206-
WiFiDrv::config(2, (uint32_t)local_ip, (uint32_t)gateway, 0);
207-
WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
213+
IPAddress subnet(255, 255, 255, 0);
214+
config(local_ip, dns_server, gateway, subnet);
208215
}
209216

210217
void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)

0 commit comments

Comments
 (0)