aboutsummaryrefslogtreecommitdiff
path: root/libraries/WiFi/WiFi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/WiFi/WiFi.cpp')
-rw-r--r--libraries/WiFi/WiFi.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/libraries/WiFi/WiFi.cpp b/libraries/WiFi/WiFi.cpp
index c0cb001..f209280 100644
--- a/libraries/WiFi/WiFi.cpp
+++ b/libraries/WiFi/WiFi.cpp
@@ -8,7 +8,7 @@ extern "C" {
}
// XXX: don't make assumptions about the value of MAX_SOCK_NUM.
-int16_t WiFiClass::_state[MAX_SOCK_NUM] = { 0, 0, 0, 0 };
+int16_t WiFiClass::_state[MAX_SOCK_NUM] = { NA_STATE, NA_STATE, NA_STATE, NA_STATE };
uint16_t WiFiClass::_server_port[MAX_SOCK_NUM] = { 0, 0, 0, 0 };
WiFiClass::WiFiClass()
@@ -71,8 +71,7 @@ int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
{
delay(WL_DELAY_START_CONNECTION);
status = WiFiDrv::getConnectionStatus();
- }
- while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
+ }while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
}else{
status = WL_CONNECT_FAILED;
}
@@ -99,6 +98,39 @@ int WiFiClass::begin(char* ssid, const char *passphrase)
return status;
}
+void WiFiClass::config(IPAddress local_ip)
+{
+ WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
+}
+
+void WiFiClass::config(IPAddress local_ip, IPAddress dns_server)
+{
+ WiFiDrv::config(1, (uint32_t)local_ip, 0, 0);
+ WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
+}
+
+void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway)
+{
+ WiFiDrv::config(2, (uint32_t)local_ip, (uint32_t)gateway, 0);
+ WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
+}
+
+void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
+{
+ WiFiDrv::config(3, (uint32_t)local_ip, (uint32_t)gateway, (uint32_t)subnet);
+ WiFiDrv::setDNS(1, (uint32_t)dns_server, 0);
+}
+
+void WiFiClass::setDNS(IPAddress dns_server1)
+{
+ WiFiDrv::setDNS(1, (uint32_t)dns_server1, 0);
+}
+
+void WiFiClass::setDNS(IPAddress dns_server1, IPAddress dns_server2)
+{
+ WiFiDrv::setDNS(2, (uint32_t)dns_server1, (uint32_t)dns_server2);
+}
+
int WiFiClass::disconnect()
{
return WiFiDrv::disconnect();