Compare commits
2 Commits
bd422c3991
...
933ce71db4
| Author | SHA1 | Date | |
|---|---|---|---|
| 933ce71db4 | |||
| 4ca795501b |
@ -2,7 +2,6 @@
|
|||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Gärbox</title>
|
<title>Gärbox</title>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
31
data/Greenhouse/http/index.html
Normal file
31
data/Greenhouse/http/index.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Gewächshaus</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 4vw;
|
||||||
|
margin: 1em;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Gewächshaus</h1>
|
||||||
|
TODO
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1,6 +1,5 @@
|
|||||||
#ifdef NODE_FERMENTER
|
#ifdef NODE_FERMENTER
|
||||||
|
|
||||||
#include <ESPAsyncWebServer.h>
|
|
||||||
#include <LedControl.h>
|
#include <LedControl.h>
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
@ -9,6 +8,7 @@
|
|||||||
#include "patrix/PIDController.h"
|
#include "patrix/PIDController.h"
|
||||||
#include "patrix/PWMOutput.h"
|
#include "patrix/PWMOutput.h"
|
||||||
#include "patrix/Rotary.h"
|
#include "patrix/Rotary.h"
|
||||||
|
#include "patrix/http.h"
|
||||||
|
|
||||||
#define HEATER_POWER_W 30
|
#define HEATER_POWER_W 30
|
||||||
|
|
||||||
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
void rotaryCallback(int delta);
|
void rotaryCallback(int delta);
|
||||||
|
|
||||||
AsyncWebServer server(80);
|
|
||||||
|
|
||||||
DS18B20 ds18b20("DS18B20", D4);
|
DS18B20 ds18b20("DS18B20", D4);
|
||||||
|
|
||||||
DS18B20Sensor input(ds18b20, 0, "");
|
DS18B20Sensor input(ds18b20, 0, "");
|
||||||
@ -171,21 +169,7 @@ void httpTargetAdd(AsyncWebServerRequest *request) {
|
|||||||
httpStatus(request);
|
httpStatus(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpNotFound(AsyncWebServerRequest *request) {
|
|
||||||
if (request->method() == HTTP_OPTIONS) {
|
|
||||||
request->send(200);
|
|
||||||
} else {
|
|
||||||
request->send(404, "text/plain", "not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void patrixSetup() {
|
void patrixSetup() {
|
||||||
if (LittleFS.begin()) {
|
|
||||||
Log.info("Filesystem mounted.");
|
|
||||||
} else {
|
|
||||||
Log.error("Failed to mount filesystem!");
|
|
||||||
}
|
|
||||||
|
|
||||||
ds18b20.setup();
|
ds18b20.setup();
|
||||||
heater.setup();
|
heater.setup();
|
||||||
rotary.setup();
|
rotary.setup();
|
||||||
@ -193,16 +177,10 @@ void patrixSetup() {
|
|||||||
targetFileSetup();
|
targetFileSetup();
|
||||||
pid.setup();
|
pid.setup();
|
||||||
|
|
||||||
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
|
|
||||||
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Methods", "GET, POST, PUT");
|
|
||||||
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
||||||
server.serveStatic("/", LittleFS, "/http/", "max-age=86400").setDefaultFile("index.html");
|
|
||||||
server.on("/status", httpStatus);
|
server.on("/status", httpStatus);
|
||||||
server.on("/status/", httpStatus);
|
server.on("/status/", httpStatus);
|
||||||
server.on("/target/add", httpTargetAdd);
|
server.on("/target/add", httpTargetAdd);
|
||||||
server.on("/target/add/", httpTargetAdd);
|
server.on("/target/add/", httpTargetAdd);
|
||||||
server.onNotFound(httpNotFound);
|
|
||||||
server.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void patrixLoop() {
|
void patrixLoop() {
|
||||||
|
|||||||
@ -1,17 +1,26 @@
|
|||||||
|
#include <LittleFS.h>
|
||||||
#include "Patrix.h"
|
#include "Patrix.h"
|
||||||
|
#include "http.h"
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Log.info("Startup.");
|
Log.info("Startup.");
|
||||||
|
if (LittleFS.begin()) {
|
||||||
|
Log.info("Filesystem mounted.");
|
||||||
|
} else {
|
||||||
|
Log.error("Failed to mount filesystem!");
|
||||||
|
}
|
||||||
wifiConnect();
|
wifiConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
wifiLoop();
|
wifiLoop();
|
||||||
mqttLoop();
|
mqttLoop();
|
||||||
if (isAfterBootDelay()) {
|
if (isBootDelayComplete()) {
|
||||||
if (isSetupTimeAfterBootDelay()) {
|
if (isSetupTimeAfterBootDelay()) {
|
||||||
patrixSetup();
|
patrixSetup();
|
||||||
|
httpSetup();
|
||||||
}
|
}
|
||||||
patrixLoop();
|
patrixLoop();
|
||||||
|
httpLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
39
src/patrix/http.cpp
Normal file
39
src/patrix/http.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "http.h"
|
||||||
|
#include "mqtt.h"
|
||||||
|
|
||||||
|
#include <LittleFS.h>
|
||||||
|
|
||||||
|
AsyncWebServer server(80);
|
||||||
|
|
||||||
|
bool httpDoRestart = false;
|
||||||
|
|
||||||
|
void httpNotFound(AsyncWebServerRequest *request) {
|
||||||
|
if (request->method() == HTTP_OPTIONS) {
|
||||||
|
request->send(200);
|
||||||
|
} else {
|
||||||
|
request->send(404, "text/plain", "not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void httpRestart([[maybe_unused]] AsyncWebServerRequest *request) {
|
||||||
|
httpDoRestart = true;
|
||||||
|
request->send(200, "application/json", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
void httpSetup() {
|
||||||
|
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Methods", "GET, POST, PUT");
|
||||||
|
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Headers", "Content-Type");
|
||||||
|
server.on("/restart", httpRestart);
|
||||||
|
server.serveStatic("/", LittleFS, "/http/", "max-age=86400").setDefaultFile("index.html");
|
||||||
|
server.onNotFound(httpNotFound);
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void httpLoop() {
|
||||||
|
if (httpDoRestart) {
|
||||||
|
Log.info("Restarting...");
|
||||||
|
delay(500);
|
||||||
|
EspClass::restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/patrix/http.h
Normal file
12
src/patrix/http.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef HELLIGKEIT_HTTP_H
|
||||||
|
#define HELLIGKEIT_HTTP_H
|
||||||
|
|
||||||
|
#include <ESPAsyncWebServer.h>
|
||||||
|
|
||||||
|
extern AsyncWebServer server;
|
||||||
|
|
||||||
|
void httpSetup();
|
||||||
|
|
||||||
|
void httpLoop();
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -156,6 +156,6 @@ bool isSetupTimeAfterBootDelay() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAfterBootDelay() {
|
bool isBootDelayComplete() {
|
||||||
return bootDelayOver;
|
return bootDelayOver;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ bool isWifiConnected();
|
|||||||
|
|
||||||
bool isSetupTimeAfterBootDelay();
|
bool isSetupTimeAfterBootDelay();
|
||||||
|
|
||||||
bool isAfterBootDelay();
|
bool isBootDelayComplete();
|
||||||
|
|
||||||
uint64_t uptimeMillis();
|
uint64_t uptimeMillis();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user