Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
domoticsduino committed Sep 16, 2021
1 parent 72398f3 commit fd71901
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
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
39 changes: 39 additions & 0 deletions ddwifi.cpp
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);
}
24 changes: 24 additions & 0 deletions ddwifi.h
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

0 comments on commit fd71901

Please sign in to comment.