Clean up
parent
f8f47a94f0
commit
f0ca858dc5
|
|
@ -42,63 +42,6 @@ void WebServer::setup() {
|
||||||
this->debugController->printLn("Server started");
|
this->debugController->printLn("Server started");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebServer::handleClient() {
|
|
||||||
this->server->handleClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebServer::redirectTarget(String targetUri) {
|
|
||||||
// Send them back to the Root Directory
|
|
||||||
this->server->sendHeader("Location", targetUri, true);
|
|
||||||
this->server->sendHeader("Cache-Control", "no-cache, no-store");
|
|
||||||
this->server->sendHeader("Pragma", "no-cache");
|
|
||||||
this->server->sendHeader("Expires", "-1");
|
|
||||||
this->server->send(302, "text/plain", "");
|
|
||||||
this->server->client().stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WebServer::redirectHome() {
|
|
||||||
this->redirectTarget("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebServer::displayPrinterStatus() {
|
|
||||||
|
|
||||||
/*BasePrinterClient *printerClient = this->globalDataController->getPrinterClient();
|
|
||||||
String html = "";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (printerClient->getError() != "") {
|
|
||||||
html += "Status: Offline<br>";
|
|
||||||
html += "Reason: " + printerClient->getError() + "<br>";
|
|
||||||
} else {
|
|
||||||
html += "Status: " + printerClient->getStateAsText();
|
|
||||||
if (printerClient->isPSUoff() && this->globalDataController->hasPrinterPsu()) {
|
|
||||||
html += ", PSU off";
|
|
||||||
}
|
|
||||||
html += "<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printerClient->isPrinting()) {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
html += "</p></div></div>";
|
|
||||||
|
|
||||||
html += "<div class='w3-cell-row' style='width:100%'><h2>Time: " + displayTime + "</h2></div>";
|
|
||||||
|
|
||||||
this->server->sendContent(html); // spit out what we got
|
|
||||||
html = "";
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WebServer::findMDNS() {
|
void WebServer::findMDNS() {
|
||||||
return; // nothing to do here
|
return; // nothing to do here
|
||||||
|
|
@ -133,6 +76,36 @@ void WebServer::findMDNS() {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Handle clients of webserver
|
||||||
|
*/
|
||||||
|
void WebServer::handleClient() {
|
||||||
|
this->server->handleClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Redirect incomming transmission to other taget
|
||||||
|
*/
|
||||||
|
void WebServer::redirectTarget(String targetUri) {
|
||||||
|
// Send them back to the Root Directory
|
||||||
|
this->server->sendHeader("Location", targetUri, true);
|
||||||
|
this->server->sendHeader("Cache-Control", "no-cache, no-store");
|
||||||
|
this->server->sendHeader("Pragma", "no-cache");
|
||||||
|
this->server->sendHeader("Expires", "-1");
|
||||||
|
this->server->send(302, "text/plain", "");
|
||||||
|
this->server->client().stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Redirect incomming transmission to dashboard
|
||||||
|
*/
|
||||||
|
void WebServer::redirectHome() {
|
||||||
|
this->redirectTarget("/");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handle authentification on all subsites
|
* @brief Handle authentification on all subsites
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ public:
|
||||||
boolean authentication();
|
boolean authentication();
|
||||||
void redirectHome();
|
void redirectHome();
|
||||||
void redirectTarget(String targetUri);
|
void redirectTarget(String targetUri);
|
||||||
void displayPrinterStatus();
|
|
||||||
void handleSystemReset();
|
void handleSystemReset();
|
||||||
void handleWifiReset();
|
void handleWifiReset();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -205,9 +205,13 @@ void WebserverMemoryVariables::sendMainPage(ESP8266WebServer *server, GlobalData
|
||||||
lineData.replace("%V%", String(printerConfigs[i].remoteAddress) + ":" + String(printerConfigs[i].remotePort));
|
lineData.replace("%V%", String(printerConfigs[i].remoteAddress) + ":" + String(printerConfigs[i].remotePort));
|
||||||
server->sendContent(lineData);
|
server->sendContent(lineData);
|
||||||
|
|
||||||
|
String currentState = globalDataController->getPrinterStateAsText(&printerConfigs[i]);
|
||||||
|
if (printerConfigs[i].isPSUoff && printerConfigs[i].hasPsuControl) {
|
||||||
|
currentState += ", PSU off";
|
||||||
|
}
|
||||||
lineData = FPSTR(MAINPAGE_ROW_PRINTER_BLOCK_LINE);
|
lineData = FPSTR(MAINPAGE_ROW_PRINTER_BLOCK_LINE);
|
||||||
lineData.replace("%T%", "State");
|
lineData.replace("%T%", "State");
|
||||||
lineData.replace("%V%", globalDataController->getPrinterStateAsText(&printerConfigs[i]));
|
lineData.replace("%V%", currentState);
|
||||||
server->sendContent(lineData);
|
server->sendContent(lineData);
|
||||||
|
|
||||||
if (printerConfigs[i].state != PRINTER_STATE_STANDBY) {
|
if (printerConfigs[i].state != PRINTER_STATE_STANDBY) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <base64.h>
|
||||||
|
#include "Debug.h"
|
||||||
|
#include "../Network/JsonRequestClient.h"
|
||||||
|
#include "SensorDataStruct.h"
|
||||||
|
#include "../../include/MemoryHelper.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Basic function definitions for an sensor client like an interface
|
||||||
|
*/
|
||||||
|
class BaseSensorClient {
|
||||||
|
public:
|
||||||
|
virtual String getType() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset all dynamic variables for sensor
|
||||||
|
* @param sensorData Handle to sensor struct
|
||||||
|
*/
|
||||||
|
static void resetData(SensorDataStruct *sensorData) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <base64.h>
|
||||||
|
|
||||||
|
#define SENSOR_CLIENT_BME280 (int)0
|
||||||
|
#define SENSOR_CLIENT_BME680 (int)1
|
||||||
|
#define SENSOR_CLIENT_HTU21D (int)2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int sensType;
|
||||||
|
char error[120];
|
||||||
|
} SensorDataStruct;
|
||||||
Loading…
Reference in New Issue