From 3d184773c1c753db1f096e54e80d25121bd887e2 Mon Sep 17 00:00:00 2001 From: bonamin Date: Mon, 29 Dec 2025 20:38:52 +0200 Subject: [PATCH] Added Extra Heartbeat Metrics and Separated HTML Page --- vesper/src/SettingsWebServer/SettingsPage.h | 281 ++++++++++++++++++ .../SettingsWebServer/SettingsWebServer.cpp | 265 +---------------- vesper/vesper.ino | 6 +- 3 files changed, 298 insertions(+), 254 deletions(-) create mode 100644 vesper/src/SettingsWebServer/SettingsPage.h diff --git a/vesper/src/SettingsWebServer/SettingsPage.h b/vesper/src/SettingsWebServer/SettingsPage.h new file mode 100644 index 0000000..3b7505e --- /dev/null +++ b/vesper/src/SettingsWebServer/SettingsPage.h @@ -0,0 +1,281 @@ +/* + * ═══════════════════════════════════════════════════════════════════════════════════ + * SETTINGSPAGE.H - HTML Content for Settings Web Interface + * ═══════════════════════════════════════════════════════════════════════════════════ + * + * This file contains the HTML/CSS/JavaScript for the VESPER network settings page. + * Separated from the main implementation for better maintainability. + * + * 📋 VERSION: 1.0 + * 📅 DATE: 2025-12-29 + * 👨‍💻 AUTHOR: Advanced Bell Systems + * ═══════════════════════════════════════════════════════════════════════════════════ + */ + +#pragma once + +// HTML template for the settings page +// Use placeholders for dynamic content: +// %MODE_BADGE_CLASS% - "ap" or "station" +// %MODE_TEXT% - "AP Mode" or "Station Mode" +// %CURRENT_IP% - Current IP address +// %DEVICE_UID% - Device unique ID +// %FW_VERSION% - Firmware version +// %AP_ACTIVE_CLASS% - "active" if in AP mode, "" otherwise +// %STATION_ACTIVE_CLASS% - "active" if in station mode, "" otherwise +// %SELECTED_MODE% - "ap" or "station" + +const char SETTINGS_PAGE_HTML[] PROGMEM = R"rawliteral( + + + + + + VESPER Network Settings + + + +
+
+

VESPER Settings

+

Network Configuration

+
+ +
+
+ Current Mode: + + + %MODE_TEXT% + + +
+
+ IP Address: + %CURRENT_IP% +
+
+ Device UID: + %DEVICE_UID% +
+
+ Firmware: + v%FW_VERSION% +
+
+ +
Select Network Mode
+ +
+
+

AP Mode

+

Direct Connection
192.168.4.1

+
+
+

Router Mode

+

Connect via Router
WiFi/Ethernet

+
+
+ + + + +
+ Device will reboot after applying changes. Make sure to reconnect to the correct network after reboot. +
+ + +
+ + + + +)rawliteral"; diff --git a/vesper/src/SettingsWebServer/SettingsWebServer.cpp b/vesper/src/SettingsWebServer/SettingsWebServer.cpp index 35bf2ad..1a56004 100644 --- a/vesper/src/SettingsWebServer/SettingsWebServer.cpp +++ b/vesper/src/SettingsWebServer/SettingsWebServer.cpp @@ -5,6 +5,7 @@ */ #include "SettingsWebServer.hpp" +#include "SettingsPage.h" #include "../ConfigManager/ConfigManager.hpp" #include "../Networking/Networking.hpp" #include "../Logging/Logging.hpp" @@ -106,260 +107,18 @@ String SettingsWebServer::generateSettingsHTML() { String deviceUID = _configManager.getDeviceUID(); String fwVersion = _configManager.getFwVersion(); - String html = R"rawliteral( - - - - - - VESPER Network Settings - - - -
-
-

VESPER Settings

-

Network Configuration

-
+ // Load HTML template from PROGMEM + String html = String(FPSTR(SETTINGS_PAGE_HTML)); -
-
- Current Mode: - - - )rawliteral" + String(isAPMode ? "AP Mode" : "Station Mode") + R"rawliteral( - - -
-
- IP Address: - )rawliteral" + currentIP + R"rawliteral( -
-
- Device UID: - )rawliteral" + deviceUID + R"rawliteral( -
-
- Firmware: - v)rawliteral" + fwVersion + R"rawliteral( -
-
- -
Select Network Mode
- -
-
-

AP Mode

-

Direct Connection
192.168.4.1

-
-
-

Router Mode

-

Connect via Router
WiFi/Ethernet

-
-
- - - - -
- Device will reboot after applying changes. Make sure to reconnect to the correct network after reboot. -
- - -
- - - - -)rawliteral"; + // Replace placeholders with dynamic values + html.replace("%MODE_BADGE_CLASS%", isAPMode ? "ap" : "station"); + html.replace("%MODE_TEXT%", isAPMode ? "AP Mode" : "Station Mode"); + html.replace("%CURRENT_IP%", currentIP); + html.replace("%DEVICE_UID%", deviceUID); + html.replace("%FW_VERSION%", fwVersion); + html.replace("%AP_ACTIVE_CLASS%", isAPMode ? "active" : ""); + html.replace("%STATION_ACTIVE_CLASS%", !isAPMode ? "active" : ""); + html.replace("%SELECTED_MODE%", isAPMode ? "ap" : "station"); return html; } diff --git a/vesper/vesper.ino b/vesper/vesper.ino index 81e42a4..ddb7da3 100644 --- a/vesper/vesper.ino +++ b/vesper/vesper.ino @@ -480,7 +480,11 @@ void loop() // 🔥 DEBUG: Log every 10 seconds to verify we're still running static unsigned long lastLog = 0; if (millis() - lastLog > 10000) { - LOG_DEBUG("❤️ Loop alive, free heap: %d", ESP.getFreeHeap()); + LOG_DEBUG("❤️ Loop alive | Free heap: %d bytes (%.1f KB) | Min free: %d | Largest block: %d", + ESP.getFreeHeap(), + ESP.getFreeHeap() / 1024.0, + ESP.getMinFreeHeap(), + ESP.getMaxAllocHeap()); lastLog = millis(); }