diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp
index 9e625d08..1a0c77b5 100644
--- a/src/sys/svc/hasp_http.cpp
+++ b/src/sys/svc/hasp_http.cpp
@@ -1275,8 +1275,12 @@ static void webHandleWifiConfig()
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
if(WiFi.getMode() == WIFI_STA) {
add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
+#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
+ } else {
+ add_form_button(httpMessage, F(D_HTTP_FIRMWARE_UPGRADE), F("/firmware"));
+#endif // ARDUINO_ARCH_ESP
}
-#endif
+#endif // HASP_USE_WIFI
httpMessage += F("");
@@ -1286,61 +1290,6 @@ static void webHandleWifiConfig()
webSendFooter();
}
-#if HASP_USE_CAPTIVE_PORTAL > 0
-// I'm not an experienced programmer, this was the only way I managed to get it to work..
-static void webHandleCaptivePortalWifiConfig()
-{ // http://plate01/config/wifi
- if(!httpIsAuthenticated(F("config/wifi"))) return;
-
- { // Send Content
- StaticJsonDocument<256> settings;
- wifiGetConfig(settings.to");
- httpMessage += haspDevice.get_hostname();
- httpMessage += F("
");
- httpMessage += F("" D_HTTP_WIFI_SETTINGS "
");
-
- // Form
- httpMessage += F("");
-
-#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
- if(WiFi.getMode() == WIFI_STA) {
- add_form_button(httpMessage, F(D_BACK_ICON D_HTTP_CONFIGURATION), F("/config"));
- }
-#endif
-
- webSendHeader(haspDevice.get_hostname(), httpMessage.length(), false);
- webServer.sendContent(httpMessage);
- }
- webSendFooter();
-}
-#endif // HASP_USE_CAPTIVE_PORTAL
-
#endif // HASP_USE_WIFI
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1983,7 +1932,7 @@ static void webHandleHaspConfig()
#endif // HASP_USE_CONFIG
////////////////////////////////////////////////////////////////////////////////////////////////////
-static void httpHandleNotFound()
+static void httpHandleFileFromFlash()
{ // webServer 404
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
int statuscode = handleFileRead(webServer.uri());
@@ -2228,46 +2177,6 @@ static void webSendCssVars()
webSendCached(200, PSTR("text/css"), HTTP_CSS.c_str(), HTTP_CSS.length());
}
-/*
-// Do not keep JS in memory because it is cached in the browser
-static void webSendJavascript()
-{
- // Refresh screenshot
- String javascript = F("function aref(t){setTimeout(function() {ref('');}, t*1000)}"
- "function ref(a){ var t=new "
- "Date().getTime();document.getElementById('bmp').src='?a='+a+'&q='+t;return false;};");
- // This string can be gzipped:
- javascript +=
- "function about(){document.getElementById('doc').innerHTML='" D_MANUFACTURER
- "
Copyright© 2019-2022 Francis Van RoieMIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and " - "associated documentation files(the \"Software\"), to deal in the Software without restriction, including " - "without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell " - "copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the " - "following conditions:
" - "The above copyright notice and this permission notice shall be included in all copies or substantial " - "portions of the Software.
THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, " - "EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR " - "PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, " - "DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN " - "CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Based on the previous work of the following open source developers:
" - "Copyright© 2019 Allen Derusha allen@derusha.orgMIT License
" - "Copyright© 2021 LVGL KftMIT License
" - "Copyright© 2020-2021 Francis Van RoieMIT License
" - "Copyright© 2020 Bodmer (https://github.com/Bodmer) All rights " - "reserved.FreeBSD License
" - "includes parts from the Adafruit_GFX libraryCopyright© 2012 Adafruit Industries. All " - "rights reservedBSD License
" - "Copyright© 2014-2021 Benoit BLANCHONMIT License
" - "Copyright© 2008-2015 Nicholas O'LearyMIT License
" - "Copyright© 2017,2018 Thijs Elenbaas, MrRobot62, rahuldeo2047, NOX73, dhylands, " - "Josha blemasle, mfalkviddMIT License
" - "Copyright© Project NayukiMIT License
" - "Copyright© 2018 Brian T. ParkMIT License
';}"; - webSendCached(200, PSTR("text/javascript"), javascript.c_str(), javascript.length()); -} -*/ //////////////////////////////////////////////////////////////////////////////////////////////////// static inline void webStartConfigPortal() @@ -2276,15 +2185,14 @@ static inline void webStartConfigPortal() // if DNSServer is started with "*" for domain name, it will reply with // provided IP to all DNS request dnsServer.start(DNS_PORT, "*", apIP); - // replay to all requests with same HTML - webServer.onNotFound([]() { - webHandleCaptivePortalWifiConfig(); - // webServer.send(200, "text/html", responseHTML); - // webServer.on(F("/"), webHandleWifiConfig); - }); #endif // HASP_USE_CAPTIVE_PORTAL - webServer.on(F("/"), webHandleWifiConfig); + // replay to all requests with same HTML + webServer.onNotFound([]() { webHandleWifiConfig(); }); + + webServer.on(F("/style.css"), httpHandleFileFromFlash); + webServer.on(F("/script.js"), httpHandleFileFromFlash); + LOG_TRACE(TAG_HTTP, F("Wifi access point")); } @@ -2301,10 +2209,21 @@ void httpSetup() webServer.on(F("/about"), webHandleAbout); webServer.on(F("/vars.css"), webSendCssVars); // webServer.on(F("/js"), webSendJavascript); - webServer.onNotFound(httpHandleNotFound); webServer.on(UriBraces(F("/api/{}/")), webHandleApi); webServer.on(UriBraces(F("/api/config/{}/")), webHandleApiConfig); +#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) + webServer.on(F("/firmware"), webHandleFirmware); + webServer.on( + F("/update"), HTTP_POST, + []() { + webServer.send(200, "text/plain", ""); + LOG_VERBOSE(TAG_HTTP, F("Total size: %s"), webServer.hostHeader().c_str()); + }, + webHandleFirmwareUpload); + // webServer.on(F("/espfirmware"), httpHandleEspFirmware); +#endif + #if HASP_USE_WIFI > 0 // These two endpoints are needed in STA and AP mode webServer.on(F("/config"), webHandleConfig); @@ -2355,7 +2274,6 @@ void httpSetup() webServer.on(F("/info"), webHandleInfoJson); // webServer.on(F("/info"), webHandleInfo); webServer.on(F("/screenshot"), webHandleScreenshot); - webServer.on(F("/firmware"), webHandleFirmware); webServer.on(F("/reboot"), httpHandleReboot); #if HASP_USE_CONFIG > 0 @@ -2377,17 +2295,7 @@ void httpSetup() webServer.on(F("/saveConfig"), webHandleSaveConfig); webServer.on(F("/resetConfig"), httpHandleResetConfig); #endif // HASP_USE_CONFIG - -#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) - webServer.on( - F("/update"), HTTP_POST, - []() { - webServer.send(200, "text/plain", ""); - LOG_VERBOSE(TAG_HTTP, F("Total size: %s"), webServer.hostHeader().c_str()); - }, - webHandleFirmwareUpload); - // webServer.on(F("/espfirmware"), httpHandleEspFirmware); -#endif + webServer.onNotFound(httpHandleFileFromFlash); LOG_INFO(TAG_HTTP, F(D_SERVICE_STARTED)); // webStart(); Wait for network connection