-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddwifi.cpp
39 lines (29 loc) · 787 Bytes
/
ddwifi.cpp
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
/* 1.0.0 VERSION */
#include "ddwifi.h"
DDWifi::DDWifi(const char *ssid, const char *password, const char *hostname, int led)
{
this->_ssid = ssid;
this->_password = password;
this->_hostname = hostname;
this->_led = led;
}
void DDWifi::connect()
{
WiFi.mode(WIFI_STA);
WiFi.begin(this->_ssid, this->_password);
WiFi.hostname(this->_hostname);
writeToSerial("Connecting to WiFi ", false);
writeToSerial(this->_ssid, true);
while (WiFi.status() != WL_CONNECTED)
{
digitalWrite(this->_led, HIGH);
delay(500);
digitalWrite(this->_led, LOW);
writeToSerial(".", false);
}
writeToSerial("", true);
writeToSerial("Connected to ", false);
writeToSerial(this->_ssid, true);
writeToSerial("IP address: ", false);
writeToSerial(WiFi.localIP().toString(), true);
}