-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWifi.ino
47 lines (44 loc) · 1.07 KB
/
Wifi.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
void initWifiModoAP()
{
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(local_IP, gateway, subnet);
WiFi.softAP(ssid);
IPAddress myIP = WiFi.softAPIP();
if (DEBUG)
{
Serial.print("AP IP address: ");
Serial.println(myIP);
}
dnsServer.start(DNS_PORT, "*", local_IP);
}
bool IsWiFiNotConnected()
{
return WiFi.status() != WL_CONNECTED;
}
void WaitForConnection()
{
unsigned long timeout = millis() + WIFI_STA_TIMEOUT;
while (IsWiFiNotConnected() && millis() < timeout)
{
delay(100);
}
if (DEBUG) {
if (IsWiFiNotConnected()) {
Serial.println("Erro ao conectar no WiFi!");
}
else {
Serial.println("STA Connection established!");
Serial.println("");
Serial.print("Connected to ");
Serial.println(getWifiSsid());
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
}
}
void initWifiModoSTA()
{
WiFi.mode(WIFI_STA);
WiFi.begin(getWifiSsid(), getWifiPassword());
WaitForConnection();
}