From feac3bbdf4c569875e2a5fbb36c59b96a43276b3 Mon Sep 17 00:00:00 2001 From: Yurii Date: Sat, 13 Jan 2024 13:26:24 +0300 Subject: [PATCH] feat: display a message on home page if the file system is not flashed --- src/PortalTask.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/PortalTask.h b/src/PortalTask.h index affad2a..fe1f643 100644 --- a/src/PortalTask.h +++ b/src/PortalTask.h @@ -206,7 +206,7 @@ protected: String plain = this->webServer->arg(0); Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/backup/restore %d bytes: %s"), plain.length(), plain.c_str()); - if (plain.length() < 2) { + if (plain.length() < 5) { this->webServer->send(406); return; @@ -271,7 +271,7 @@ protected: String plain = this->webServer->arg(0); Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/network/settings %d bytes: %s"), plain.length(), plain.c_str()); - if (plain.length() < 2) { + if (plain.length() < 5) { this->webServer->send(406); return; @@ -393,7 +393,7 @@ protected: String plain = this->webServer->arg(0); Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/settings %d bytes: %s"), plain.length(), plain.c_str()); - if (plain.length() < 2) { + if (plain.length() < 5) { this->webServer->send(406); return; @@ -449,7 +449,7 @@ protected: String plain = this->webServer->arg(0); Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Request /api/vars %d bytes: %s"), plain.length(), plain.c_str()); - if (plain.length() < 2) { + if (plain.length() < 5) { this->webServer->send(406); return; @@ -480,7 +480,11 @@ protected: this->webServer->onNotFound([this]() { Log.straceln(FPSTR(L_PORTAL_WEBSERVER), F("Page not found, uri: %s"), this->webServer->uri().c_str()); - if (tNetwork->isApEnabled()) { + const String uri = this->webServer->uri(); + if (uri.equals("/")) { + this->webServer->send(200, "text/plain", F("The file system is not flashed!")); + + } else if (tNetwork->isApEnabled()) { this->onCaptivePortal(); } else {