Wemos build #3
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
.autogit
|
||||
*.txt
|
||||
*.pdf
|
||||
*.pdf
|
||||
output/
|
||||
Settings.h
|
||||
.vscode
|
BIN
LiquidCrystal_I2C-master.zip
Normal file
BIN
LiquidCrystal_I2C-master.zip
Normal file
Binary file not shown.
26
Settings.h.original
Normal file
26
Settings.h.original
Normal file
@ -0,0 +1,26 @@
|
||||
//* **EINSTELLUNGEN** *//
|
||||
#define SETUPTIMEOUT 500
|
||||
|
||||
// So, the minimum sampling period is the minimum time
|
||||
// interval that we need to wait between two consecutive
|
||||
// measurements from the sensor. In the case of the DHT22,
|
||||
// this value is of 2 seconds [1].
|
||||
|
||||
static const unsigned long MESS_REFRESH_INTERVAL = 10000; // ms getMinimumSamplingPeriod == 2 sec
|
||||
static const unsigned long SCHALT_REFRESH_INTERVAL = 60000; // ms
|
||||
static const unsigned long LCD_REFRESH_INTERVAL = 500; // ms
|
||||
|
||||
const int uT = 1; //Abschalt-Temperatur in °C
|
||||
const int oT = 4; //Einschalt-Temperatur in °C
|
||||
|
||||
/*
|
||||
Truhe truhen[] = {
|
||||
Truhe("Truhe 1", 2, 8),
|
||||
Truhe("Truhe 2", 3, 9),
|
||||
};*/
|
||||
//Name, Relaypin, DTH Pin
|
||||
Truhe truhen[] = {
|
||||
Truhe("Truhe 1", D0, D2),
|
||||
};
|
||||
|
||||
//LiquidCrystal_I2C lcd(0x3F, 0, 0, 0, 0, 0, 0, 0, 0, POSITIVE); //0x3F = Adresse des Displays
|
@ -1,144 +1,18 @@
|
||||
#include <DHT.h> //Setup Sensoren
|
||||
#include <avr/wdt.h>
|
||||
|
||||
#include <SD.h> //Setup SD SDK=D13, MOSI=D11, MISO=D12
|
||||
|
||||
#include <Wire.h> //Setup LCD
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); //0x3F = Adresse des Displays
|
||||
LiquidCrystal_I2C lcd(0x3F,16,2); //0x3F = Adresse des Displays
|
||||
|
||||
#include "Truhe.h"
|
||||
#include "Settings.h"
|
||||
#include "Webserver.h"
|
||||
|
||||
static unsigned long last_lcd_time = 0;
|
||||
static unsigned long last_mess_time = 0;
|
||||
static unsigned long last_schalt_time = 0;
|
||||
|
||||
class Truhe {
|
||||
private:
|
||||
int _relay;
|
||||
DHT _dht;
|
||||
int _stat = -1;
|
||||
int _cur_temp = 0;
|
||||
int _updlcd = 0;
|
||||
String _name = "";
|
||||
public:
|
||||
Truhe(String name, int relay, int dhtpin, int dhttype) {
|
||||
_name = name;
|
||||
_relay = relay;
|
||||
_dht.setup(dhtpin);
|
||||
pinMode(_relay, OUTPUT);
|
||||
};
|
||||
|
||||
void mess() {
|
||||
//Serial.println(String(_name) + " mess()");
|
||||
//Serial.print("Minimum Sampling Period: ");
|
||||
//Serial.println(_dht.getMinimumSamplingPeriod());
|
||||
//delay(_dht.getMinimumSamplingPeriod());
|
||||
_cur_temp = _dht.getTemperature();
|
||||
//Serial.println(String(_name) + "\t\t" + String(_cur_temp) + " grad gelesen");
|
||||
};
|
||||
|
||||
void log(File logfile) {
|
||||
//Serial.println(String(_name) + " log()");
|
||||
String logdata = String(_name) + "\t" + String(_cur_temp) + "\t" + String(_stat);
|
||||
logfile.println(logdata);
|
||||
}
|
||||
|
||||
void updateLCD(int row) {
|
||||
//Serial.println(String(_name) + " updateLCD("+String(row)+")");
|
||||
//LCD-Anzeige
|
||||
lcd.setCursor(0, row); //...(Zeichen,Zeile);
|
||||
lcd.print(_name + " " + String(_updlcd));
|
||||
|
||||
lcd.setCursor(8, row);
|
||||
lcd.print(" ");
|
||||
//Serial.println(sizeof(String(_cur_temp))/2);
|
||||
lcd.setCursor(11 - sizeof(String(_cur_temp))/2, row);
|
||||
lcd.setCursor(8, row);
|
||||
lcd.print(String(_cur_temp));
|
||||
lcd.setCursor(11, row);
|
||||
lcd.print("\337");
|
||||
lcd.setCursor(13, row);
|
||||
if (_stat == -1) {
|
||||
lcd.print("-");
|
||||
}
|
||||
else if (_stat == 1) {
|
||||
lcd.print("I");
|
||||
}
|
||||
else if (_stat == 0) {
|
||||
lcd.print("O");
|
||||
}
|
||||
if(_updlcd == 0){
|
||||
lcd.setCursor(15, row);
|
||||
lcd.print(String("|"));
|
||||
//Serial.println(String(_name) + " updateLCD("+String(row)+") .");
|
||||
_updlcd = 1;
|
||||
}else{
|
||||
lcd.setCursor(15, row);
|
||||
lcd.print(String("-"));
|
||||
//Serial.println(String(_name) + " updateLCD("+String(row)+") ");
|
||||
_updlcd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void schalt(int oT, int uT) {
|
||||
Serial.print(String(_name) + " schalt() stat: " + String(_stat));
|
||||
if (_cur_temp >= oT && _stat != 1) {
|
||||
digitalWrite(_relay, LOW);
|
||||
_stat = 1;
|
||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
||||
}
|
||||
else if (_cur_temp <= uT && _stat != 0) {
|
||||
digitalWrite(_relay, HIGH);
|
||||
_stat = 0;
|
||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
||||
}
|
||||
}
|
||||
|
||||
void printName(){
|
||||
//Serial.println(_name);
|
||||
}
|
||||
};
|
||||
|
||||
//* **EINSTELLUNGEN** *//
|
||||
#define DHTTYPE DHT22
|
||||
#define SETUPTIMEOUT 500
|
||||
// So, the minimum sampling period is the minimum time
|
||||
// interval that we need to wait between two consecutive
|
||||
// measurements from the sensor. In the case of the DHT22,
|
||||
// this value is of 2 seconds [1].
|
||||
static const unsigned long MESS_REFRESH_INTERVAL = 10000; // ms getMinimumSamplingPeriod == 2 sec
|
||||
static const unsigned long SCHALT_REFRESH_INTERVAL = 10000; // ms
|
||||
static const unsigned long LCD_REFRESH_INTERVAL = 500; // ms
|
||||
const int uT = 1; //Abschalt-Temperatur in °C
|
||||
const int oT = 4; //Einschalt-Temperatur in °C
|
||||
|
||||
Truhe truhen[] = {
|
||||
Truhe("Truhe 1", 2, 8, 0),
|
||||
Truhe("Truhe 2", 3, 9, 0),
|
||||
};
|
||||
|
||||
|
||||
void setup_sd() {
|
||||
//Initialsierugn SD
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, 0); //...(Zeichen,Zeile);
|
||||
lcd.print("Init SD");
|
||||
if (!SD.begin(4)) { //Init SD_Karte mit CS auf Pin D4
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("fehlgeschlagen!");
|
||||
Serial.println("Init SD fehlgeschlagen!");
|
||||
delay(SETUPTIMEOUT);
|
||||
return;
|
||||
} else {
|
||||
lcd.setCursor(0, 1);
|
||||
lcd.print("abgeschlossen!");
|
||||
Serial.println("Init SD abgeschlossen!");
|
||||
delay(SETUPTIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
void setup_lcd() {
|
||||
//LCD
|
||||
lcd.begin(16, 2); //Starten des LCD, 16 Zeichen, 2 Zeilen
|
||||
lcd.init();
|
||||
lcd.backlight(); //Beleuchtung des Displays einschalten
|
||||
lcd.blink();
|
||||
lcd.clear();
|
||||
@ -155,13 +29,12 @@ void setup() {
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
setup_lcd();
|
||||
setup_sd();
|
||||
File logfile = SD.open("logTruhe.txt", FILE_WRITE); //Erstelle bzw. öffne log-Datei
|
||||
logfile.println("t(min)\tTruhe\tT(°C)\tStatus");
|
||||
logfile.close();
|
||||
lcd.clear();
|
||||
|
||||
wdt_enable(WDTO_1S); // Watchdog auf 1 s stellen
|
||||
for (int i = 0; i < (sizeof(truhen) / sizeof(truhen[0])); i++) {
|
||||
truhen[i].setup();
|
||||
}
|
||||
wdt_enable(WDTO_4S); // Watchdog auf 4 s stellen
|
||||
WifiSetup();
|
||||
Serial.println("Setup fi");
|
||||
}
|
||||
|
||||
@ -171,14 +44,8 @@ void loop() {
|
||||
//MESSINTERVALL
|
||||
last_mess_time = millis();
|
||||
for (int i = 0; i < (sizeof(truhen) / sizeof(truhen[0])); i++) {
|
||||
truhen[i].printName();
|
||||
truhen[i].mess();
|
||||
|
||||
File logfile = SD.open("logTruhe.txt", FILE_WRITE);
|
||||
truhen[i].log(logfile);
|
||||
logfile.close();
|
||||
}
|
||||
logfile.println();
|
||||
}
|
||||
//Serial.println("Schaltintervall: "+ String(millis() - last_schalt_time) + " " + String(SCHALT_REFRESH_INTERVAL));
|
||||
if(millis() - last_schalt_time >= SCHALT_REFRESH_INTERVAL || last_schalt_time == 0)
|
||||
@ -195,8 +62,45 @@ void loop() {
|
||||
//LCD Update INTERVALL
|
||||
last_lcd_time = millis();
|
||||
for (int i = 0; i < (sizeof(truhen) / sizeof(truhen[0])); i++) {
|
||||
truhen[i].updateLCD(i);
|
||||
//LCD-Anzeige
|
||||
lcd.setCursor(0, i); //...(Zeichen,Zeile);
|
||||
lcd.print(truhen[i].getName());
|
||||
|
||||
lcd.setCursor(8, i);
|
||||
lcd.print(" ");
|
||||
//Serial.println(sizeof(String(truhen[i].getCurTemp()))/2);
|
||||
lcd.setCursor(11 - sizeof(String(truhen[i].getCurTemp()))/2, i);
|
||||
lcd.setCursor(8, i);
|
||||
lcd.print(String(truhen[i].getCurTemp()));
|
||||
lcd.setCursor(11, i);
|
||||
lcd.print("\337");
|
||||
lcd.setCursor(13, i);
|
||||
if (truhen[i].getStat() == -1) {
|
||||
lcd.print("-");
|
||||
}
|
||||
else if (truhen[i].getStat() == 1) {
|
||||
lcd.print("I");
|
||||
}
|
||||
else if (truhen[i].getStat() == 0) {
|
||||
lcd.print("O");
|
||||
}
|
||||
else if (truhen[i].getStat() == 2) {
|
||||
lcd.setCursor(8, i);
|
||||
lcd.print("Error");
|
||||
}
|
||||
if(truhen[i].getUpdLcd() == 0){
|
||||
lcd.setCursor(15, i);
|
||||
lcd.print(String("|"));
|
||||
//Serial.println(String(truhen[i]._name) + " updateLCD("+String(i)+") .");
|
||||
truhen[i].setUpdLcd(1);
|
||||
}else{
|
||||
lcd.setCursor(15, i);
|
||||
lcd.print(String("-"));
|
||||
//Serial.println(String(truhen[i]._name) + " updateLCD("+String(i)+") ");
|
||||
truhen[i].setUpdLcd(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
server.handleClient();
|
||||
wdt_reset();
|
||||
}
|
||||
}
|
||||
|
BIN
Steuerung_Truhen.ino.d1_mini.bin
Normal file
BIN
Steuerung_Truhen.ino.d1_mini.bin
Normal file
Binary file not shown.
56
Truhe.cpp
Normal file
56
Truhe.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#include "Truhe.h"
|
||||
Truhe::Truhe(String name, int relay, uint8_t sensorpin){
|
||||
_name = name;
|
||||
_relay = relay;
|
||||
_sensorpin = sensorpin;
|
||||
_oneWire = OneWire(sensorpin);
|
||||
_sensors = DallasTemperature(&_oneWire);
|
||||
|
||||
};
|
||||
|
||||
void Truhe::setup() {
|
||||
Serial.println("Setup " + _name);
|
||||
Serial.println(_sensorpin);
|
||||
pinMode(_relay, OUTPUT);
|
||||
digitalWrite(_relay, HIGH);
|
||||
pinMode(_sensorpin, INPUT);
|
||||
_sensors.begin();
|
||||
}
|
||||
|
||||
void Truhe::mess() {
|
||||
Serial.println(String(_name) + " mess()");
|
||||
_sensors.requestTemperatures();
|
||||
_cur_temp = _sensors.getTempCByIndex(0);
|
||||
// Check if reading was successful
|
||||
if(_cur_temp != DEVICE_DISCONNECTED_C)
|
||||
{
|
||||
Serial.println(String(_name) + "\t\t" + String((int)_cur_temp) + " grad gelesen");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Error: Could not read temperature data: "+ String(_name));
|
||||
_cur_temp = 99; // Liewer warmes bier als garkenn bier
|
||||
_stat = 2;
|
||||
}
|
||||
};
|
||||
|
||||
void Truhe::schalt(int oT, int uT) {
|
||||
Serial.println(String(_name) + " schalt() stat: " + String(_stat));
|
||||
if (_cur_temp >= oT && _stat != 1 && _stat != 2) {
|
||||
digitalWrite(_relay, LOW);
|
||||
_stat = 1;
|
||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
||||
}
|
||||
else if (_cur_temp <= uT && _stat != 0 && _stat != 2) {
|
||||
digitalWrite(_relay, HIGH);
|
||||
_stat = 0;
|
||||
Serial.println("schalt " + _name + " zu " + String(_stat));
|
||||
}
|
||||
}
|
||||
int Truhe::getUpdLcd(){ return _updlcd;};
|
||||
void Truhe::setUpdLcd(int updlcd){ _updlcd = updlcd;};
|
||||
int Truhe::getRelay(){ return _relay;};
|
||||
int Truhe::getSensorPin(){return _sensorpin;};
|
||||
int Truhe::getStat(){return _stat;};
|
||||
int Truhe::getCurTemp(){return int(_cur_temp);};
|
||||
String Truhe::getName(){return _name;};
|
25
Truhe.h
Normal file
25
Truhe.h
Normal file
@ -0,0 +1,25 @@
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
class Truhe {
|
||||
private:
|
||||
OneWire _oneWire;
|
||||
DallasTemperature _sensors;
|
||||
int _relay;
|
||||
uint8_t _sensorpin;
|
||||
int _stat = -1;
|
||||
float _cur_temp = 0;
|
||||
int _updlcd = 0;
|
||||
String _name = "";
|
||||
public:
|
||||
Truhe(String, int, uint8_t);
|
||||
void setup();
|
||||
void mess();
|
||||
void schalt(int, int);
|
||||
int getUpdLcd();
|
||||
void setUpdLcd(int);
|
||||
int getRelay();
|
||||
int getSensorPin();
|
||||
int getStat();
|
||||
int getCurTemp();
|
||||
String getName();
|
||||
};
|
185
Webserver.h
Normal file
185
Webserver.h
Normal file
@ -0,0 +1,185 @@
|
||||
// Load Wi-Fi library
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
#include <Preferences.h>
|
||||
Preferences preferences;
|
||||
ESP8266WebServer server(80);
|
||||
ESP8266HTTPUpdateServer httpUpdater;
|
||||
String header = "<!DOCTYPE html> <html>\n"
|
||||
"<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n"
|
||||
"<title>Truhensteuerung</title>\n"
|
||||
"<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n"
|
||||
"body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;} h3 {color: #444444;margin-bottom: 50px;}\n"
|
||||
"</style>\n"
|
||||
"</head>\n"
|
||||
"<body>\n"
|
||||
"<h1>Truhensteuerung Web Server</h1>\n";
|
||||
String ssid = "REPLACE_WITH_YOUR_SSID";
|
||||
String password = "REPLACE_WITH_YOUR_PASSWORD";
|
||||
unsigned long currentTime = millis();
|
||||
unsigned long previousTime= 0;
|
||||
//const long timeoutTime= 2000;
|
||||
|
||||
void WifiConnect(String _ssid, String _password){
|
||||
// Connect to Wi-Fi network with SSID and password
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(_ssid);
|
||||
WiFi.begin(_ssid, _password);
|
||||
if(WiFi.waitForConnectResult() == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected.");
|
||||
Serial.println("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("WiFi Connection failed! Restarting in SoftAP mode instead");
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAP("Truhensteuerung", "12345678");
|
||||
Serial.print("AP IP address: ");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
}
|
||||
// Print local IP address and start web server
|
||||
}
|
||||
|
||||
void handleWifiSetup(){
|
||||
String ptr = header;
|
||||
// ptr += "URI: ";
|
||||
// ptr += server.uri();
|
||||
// ptr += "<br>\nMethod: ";
|
||||
// ptr += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
// ptr += "<br>\nArguments: ";
|
||||
// ptr += server.args();
|
||||
// ptr += "<br>\n";
|
||||
for (uint8_t i = 0; i < server.args(); i++) { ptr += " " + server.argName(i) + ": " + server.arg(i) + "<br>\n"; }
|
||||
if(server.method() == HTTP_GET){
|
||||
int n = WiFi.scanNetworks(false, true);
|
||||
String ssid;
|
||||
uint8_t encryptionType;
|
||||
int32_t RSSI;
|
||||
uint8_t* BSSID;
|
||||
int32_t channel;
|
||||
bool isHidden;
|
||||
ptr += "<a href=\"/\">Home</a>";
|
||||
ptr += "<form action=\"/setup\" method=\"post\">";
|
||||
ptr +="<table style=\"width: 100%;\">\n<tr style=\"border-bottom: 5px solid #444444;\"><td></td><td>ID</td><td>SSID</td><td>Channel</td><td>RSSI</td><td></td></tr>\n";
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
WiFi.getNetworkInfo(i, ssid, encryptionType, RSSI, BSSID, channel, isHidden);
|
||||
ptr +="<tr><td><input type=\"radio\" id=\"ssid\" name=\"ssid\" value=\""+String(ssid.c_str())+"\"></td><td>"+String(i + 1)+"</td><td>"+String(ssid.c_str())+"</td><td>"+String(channel)+"</td><td>"+String(RSSI)+"dBm</td><td>"+String(encryptionType == ENC_TYPE_NONE ? "open" : "")+""+String(isHidden ? "hidden" : "")+"</td></tr>\n";
|
||||
}
|
||||
|
||||
ptr += "</table>\n";
|
||||
ptr += "<input type=\"input\" id=\"password\" name=\"password\" placeholder=\"Kennwort\" >";
|
||||
ptr += "<input type=\"submit\" id=\"submit\" name=\"submit\" >";
|
||||
ptr += "</form>";
|
||||
}else{
|
||||
ptr += "<p>\n";
|
||||
if(server.args() != 4){
|
||||
ptr += "Missing Arguments<br>\n";
|
||||
ptr += "<a href=\"/setup\">zurück</a>\n";
|
||||
}else{
|
||||
String ssid;
|
||||
String password;
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
if(server.argName(i) == "ssid"){
|
||||
ssid = server.arg(i);
|
||||
}
|
||||
if(server.argName(i) == "password"){
|
||||
password = server.arg(i);
|
||||
}
|
||||
}
|
||||
ptr += "Connecting to "+ssid+"<br>\n";
|
||||
Serial.println("Connecting to "+ssid+", "+password+"");
|
||||
WiFi.begin(ssid, password);
|
||||
if(WiFi.waitForConnectResult() == WL_CONNECTED)
|
||||
{
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected.");
|
||||
Serial.println("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
preferences.begin("my-app", false);
|
||||
preferences.putString("ssid", ssid);
|
||||
preferences.putString("password", password);
|
||||
preferences.end();
|
||||
ptr += "WiFi connected.<br>";
|
||||
// ptr += "IP address: ";
|
||||
// ptr += WiFi.localIP();
|
||||
ptr += "<br>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("WiFi Connection failed! Restarting in SoftAP mode instead");
|
||||
ptr += "WiFi Connection failed! Restarting in SoftAP mode instead<br>\n";
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAP("Truhensteuerung", "12345678");
|
||||
Serial.print("AP IP address: ");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
//ptr += "AP IP address: ";
|
||||
//ptr += WiFi.softAPIP();
|
||||
ptr += "<br>\n";
|
||||
}
|
||||
// Print local IP address and start web server
|
||||
ptr += "</p>\n";
|
||||
}
|
||||
}
|
||||
server.send(200, "text/html", ptr);
|
||||
|
||||
}
|
||||
void handleRoot(){
|
||||
String ptr = header;
|
||||
ptr += "<a href=\"/setup\">Setup Wifi</a>";
|
||||
ptr +="<table style=\"width: 100%;\">\n<tr style=\"border-bottom: 5px solid #444444;\"><td>Name</td><td>Temp</td><td>Status</td></tr>\n";
|
||||
for (int i = 0; i < (sizeof(truhen) / sizeof(truhen[0])); i++) {
|
||||
ptr +="<tr>\n<td>";
|
||||
ptr +=truhen[i].getName();
|
||||
ptr +="</td>\n<td>";
|
||||
ptr +=String(truhen[i].getCurTemp())+"℃";
|
||||
ptr +="</td>\n<td>";
|
||||
if (truhen[i].getStat() == -1) {
|
||||
ptr +="Nicht bekannt";
|
||||
}
|
||||
else if (truhen[i].getStat() == 1) {
|
||||
ptr +="An";
|
||||
}
|
||||
else if (truhen[i].getStat() == 0) {
|
||||
ptr +="Aus";
|
||||
}
|
||||
else if (truhen[i].getStat() == 2) {
|
||||
ptr +="Error";
|
||||
}
|
||||
ptr += "</td>\n</tr>\n";
|
||||
}
|
||||
ptr += "</table>\n";
|
||||
ptr +="</body>\n";
|
||||
ptr +="</html>\n";
|
||||
server.send(200, "text/html", ptr);
|
||||
}
|
||||
void handleNotFound() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += server.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += server.args();
|
||||
message += "\n";
|
||||
for (uint8_t i = 0; i < server.args(); i++) { message += " " + server.argName(i) + ": " + server.arg(i) + "\n"; }
|
||||
server.send(404, "text/plain", message);
|
||||
}
|
||||
|
||||
void WifiSetup() {
|
||||
preferences.begin("my-app", false);
|
||||
ssid = preferences.getString("ssid", ssid);
|
||||
password = preferences.getString("password", password);
|
||||
preferences.end();
|
||||
|
||||
WifiConnect(ssid, password);
|
||||
httpUpdater.setup(&server);
|
||||
server.on("/setup",handleWifiSetup);
|
||||
server.on("/",handleRoot);
|
||||
|
||||
server.begin();
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user