-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72398f3
commit fd71901
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# smarthome-fw-lib-esp8266-ddwifi | ||
# Smarthome firmware library for ESP8266 - Wifi | ||
Library with wifi functions for all projects based on ESP8266 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* 1.0.0 VERSION */ | ||
|
||
#ifndef ddwifi_h | ||
#define ddwifi_h | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <Arduino.h> | ||
#include "ddcommon.h" | ||
|
||
class DDWifi | ||
{ | ||
|
||
private: | ||
const char *_ssid; | ||
const char *_password; | ||
const char *_hostname; | ||
int _led; | ||
|
||
public: | ||
DDWifi(const char *, const char *, const char *, int); | ||
void connect(); | ||
}; | ||
|
||
#endif |