add duration to custompage

This commit is contained in:
Stephan Mühl
2023-04-01 18:32:20 +02:00
parent 01cf81397f
commit 058e9d1ba8
18 changed files with 234 additions and 425 deletions

View File

@@ -24,16 +24,17 @@ void FSWebServer::addHandler(const Uri &uri, HTTPMethod method, WebServerClass::
webserver->on(uri, method, fn);
}
void FSWebServer::onNotFound(WebServerClass::THandlerFunction fn)
{
webserver->onNotFound(fn);
}
void FSWebServer::addHandler(const Uri &uri, WebServerClass::THandlerFunction handler)
{
webserver->on(uri, HTTP_ANY, handler);
}
void FSWebServer::onNotFound(WebServerClass::THandlerFunction handler)
{
webserver->onNotFound(handler);
}
// List all files saved in the selected filesystem
bool FSWebServer::checkDir(char *dirname, uint8_t levels)
{
@@ -85,7 +86,7 @@ bool FSWebServer::begin(const char *path)
webserver->on("/edit", HTTP_PUT, std::bind(&FSWebServer::handleFileCreate, this));
webserver->on("/edit", HTTP_DELETE, std::bind(&FSWebServer::handleFileDelete, this));
#endif
//webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
webserver->onNotFound(std::bind(&FSWebServer::handleRequest, this));
webserver->on("/favicon.ico", HTTP_GET, std::bind(&FSWebServer::replyOK, this));
webserver->on("/", HTTP_GET, std::bind(&FSWebServer::handleIndex, this));
#ifdef INCLUDE_SETUP_HTM
@@ -158,6 +159,7 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
#elif defined(ESP32)
wifi_config_t conf;
esp_wifi_get_config(WIFI_IF_STA, &conf);
_ssid = reinterpret_cast<const char *>(conf.sta.ssid);
_pass = reinterpret_cast<const char *>(conf.sta.password);
#endif
@@ -167,6 +169,7 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
WiFi.begin(_ssid, _pass);
Serial.print(F("Connecting to "));
Serial.println(_ssid);
uint32_t startTime = millis();
while (WiFi.status() != WL_CONNECTED)
{
@@ -174,6 +177,8 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
Serial.print(".");
if (WiFi.status() == WL_CONNECTED)
{
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
ip = WiFi.localIP();
return ip;
}
@@ -921,4 +926,4 @@ void FSWebServer::handleStatus()
webserver->send(200, "application/json", json);
}
#endif // INCLUDE_EDIT_HTM
#endif // INCLUDE_EDIT_HTM

View File

@@ -5,7 +5,7 @@
#include <memory>
#include <typeinfo>
#include <base64.h>
//#include <FS.h>
// #include <FS.h>
#include <LittleFS.h>
#define INCLUDE_EDIT_HTM
@@ -82,11 +82,11 @@ public:
bool begin(const char *path = nullptr);
void run();
void onNotFound(WebServerClass::THandlerFunction fn);
void addHandler(const Uri &uri, HTTPMethod method, WebServerClass::THandlerFunction fn);
void addHandler(const Uri &uri, WebServerClass::THandlerFunction handler);
void onNotFound(WebServerClass::THandlerFunction handler);
void setCaptiveWebage(const char *url);
@@ -256,13 +256,12 @@ public:
return true;
}
template <typename T>
bool saveOptionValue(const char *label, T val)
{
// Öffne die Datei im Lesemodus, um den Inhalt des Dokuments beizubehalten
File file = m_filesystem->open("/config.json", "r");
DynamicJsonDocument doc(file.size()* 1.33);
DynamicJsonDocument doc(file.size() * 1.33);
if (file)
{