From 2fea8cfdd6a4ef06720f154fa1a4cfa23bf5c9d4 Mon Sep 17 00:00:00 2001
From: Marcel Peterkau
Date: Thu, 6 Jun 2024 20:28:04 +0200
Subject: [PATCH] some Bugfixes in WebUI and debugger
---
Software/data_src/index.htm | 7 ++++++-
Software/data_src/static/js/websocket.js | 18 ++++++------------
Software/src/debugger.cpp | 14 +++++++-------
Software/src/webui.cpp | 14 +++++++++++++-
4 files changed, 32 insertions(+), 21 deletions(-)
diff --git a/Software/data_src/index.htm b/Software/data_src/index.htm
index c8d12c9..1ebc688 100644
--- a/Software/data_src/index.htm
+++ b/Software/data_src/index.htm
@@ -71,7 +71,7 @@
Akkuladestand
-
0
@@ -111,6 +111,11 @@
0
0
+
+
+
+
+
diff --git a/Software/data_src/static/js/websocket.js b/Software/data_src/static/js/websocket.js
index cbe1de2..57a89a9 100644
--- a/Software/data_src/static/js/websocket.js
+++ b/Software/data_src/static/js/websocket.js
@@ -216,18 +216,12 @@ function formatTime(seconds) {
function updateFactionLogo(element, faction) {
const glowClass = "glow-active-faction";
- const factionClasses = ["faction1", "faction2", "faction3"];
-
- factionClasses.forEach((factionClass) => {
- if (
- factionClass === "faction" + faction &&
- element.classList.contains(factionClass)
- ) {
- element.classList.add(glowClass);
- } else {
- element.classList.remove(glowClass);
- }
- });
+ var factionClass = "faction" + faction;
+ if (element.classList.contains(factionClass)) {
+ element.classList.add(glowClass);
+ } else {
+ element.classList.remove(glowClass);
+ }
}
// Funktion zum Setzen des ausgewählten Werts für Dropdowns
diff --git a/Software/src/debugger.cpp b/Software/src/debugger.cpp
index 148a249..ef2bbaa 100644
--- a/Software/src/debugger.cpp
+++ b/Software/src/debugger.cpp
@@ -12,6 +12,8 @@
*/
#include "debugger.h"
+#include "utilities.h"
+#include
DebugStatus_t DebuggerStatus[dbg_cntElements];
@@ -117,8 +119,7 @@ const char helpText[][64] PROGMEM = {
"notify_error - Send error notification",
"notify_warning - Send warning notification",
"notify_success - Send success notification",
- "notify_info - Send info notification"
-};
+ "notify_info - Send info notification"};
const size_t NUM_HELP_LINES = sizeof(helpText) / sizeof(helpText[0]);
@@ -326,7 +327,7 @@ void Debug_formatPersistence()
*/
void Debug_printSystemInfo()
{
- Debug_pushMessage("Hostname: %s\n", globals.DeviceName);
+ Debug_pushMessage("Hostname: %s\n", globals.DeviceNameId);
FlashMode_t ideMode = ESP.getFlashChipMode();
Debug_pushMessage("Sdk version: %s\n", ESP.getSdkVersion());
@@ -508,10 +509,9 @@ void Debug_printHelp()
char buffer[64];
for (size_t i = 0; i < NUM_HELP_LINES; ++i)
{
- strcpy_P(buffer, (PGM_P)pgm_read_word(&(helpText[i])));
-
- // Display the help command
- Debug_pushMessage(buffer);
+ strncpy_P(buffer, helpText[i], sizeof(buffer));
+ buffer[sizeof(buffer) - 1] = '\0'; // Sicherstellen, dass der String nullterminiert ist
+ Serial.println(buffer);
}
}
diff --git a/Software/src/webui.cpp b/Software/src/webui.cpp
index 61828d3..4daf402 100644
--- a/Software/src/webui.cpp
+++ b/Software/src/webui.cpp
@@ -472,6 +472,18 @@ void Websocket_HandleButtons(uint8_t *data)
{
globals.systemStatus = sysStat_Shutdown;
}
+ else if (strcmp(identifier, "set-faction1") == 0)
+ {
+ PersistenceData.activeFaction = FACTION_1;
+ }
+ else if (strcmp(identifier, "set-faction2") == 0)
+ {
+ PersistenceData.activeFaction = FACTION_2;
+ }
+ else if (strcmp(identifier, "set-faction3") == 0)
+ {
+ PersistenceData.activeFaction = FACTION_3;
+ }
else
{
Debug_pushMessage("Got unknown Button-id '%s' from ws-client\n", identifier);
@@ -660,7 +672,7 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping)
"wifi-pass;"
"fw-version;"
"flash-version;"
- "git-revison;";
+ "git-revision;";
if (client_id > 0)
webSocket.text(client_id, mapping);