From c8e2c794a523469f394f37289f38ad36b275226a Mon Sep 17 00:00:00 2001 From: Carsten Graf Date: Mon, 9 Jun 2025 01:11:42 +0200 Subject: [PATCH] RFID fertig, empfangen geht name wird angezeigt --- data/index.html | 1 + src/communication.h | 8 ++++---- src/master.cpp | 25 +++++++++++++++++++++++++ src/rfid.h | 10 ---------- src/wificlass.h | 2 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/data/index.html b/data/index.html index e0d17db..777a82c 100644 --- a/data/index.html +++ b/data/index.html @@ -144,6 +144,7 @@ ws.onmessage = (event) => { // Namen anzeigen/verstecken - verbesserte Logik const name1Element = document.getElementById("name1"); const name2Element = document.getElementById("name2"); + if (name1 && name1.trim() !== "") { name1Element.textContent = name1; diff --git a/src/communication.h b/src/communication.h index 6a70efa..76058b0 100644 --- a/src/communication.h +++ b/src/communication.h @@ -5,14 +5,14 @@ #include -#include +#include "statusled.h" #include "timesync.h" #include "buttonassigh.h" #include "helper.h" -#include +#include "debug.h" #include -#include -#include +#include "databasebackend.h" +#include "webserverrouter.h" struct TimestampData { uint64_t lastMessageTimestamp; // Timestamp from the device diff --git a/src/master.cpp b/src/master.cpp index a97188a..0778cf2 100644 --- a/src/master.cpp +++ b/src/master.cpp @@ -96,6 +96,18 @@ void checkAutoReset() { timerData.endTime1 = 0; timerData.finishedSince1 = 0; timerData.isReady1 = true; // Zurücksetzen auf "Bereit" + + JsonDocument messageDoc; + messageDoc["firstname"] =""; + messageDoc["lastname"] = ""; + messageDoc["lane"] = "start1"; // Add lane information + + String message; + serializeJson(messageDoc, message); + + // Push the message to the frontend + pushUpdateToFrontend(message); + Serial.println("Bahn 1 automatisch auf 'Bereit' zurückgesetzt"); } } @@ -106,6 +118,19 @@ void checkAutoReset() { timerData.endTime2 = 0; timerData.finishedSince2 = 0; timerData.isReady2 = true; // Zurücksetzen auf "Bereit" + + JsonDocument messageDoc; + messageDoc["firstname"] = ""; + messageDoc["lastname"] = ""; + messageDoc["lane"] = "start2"; // Add lane information + + String message; + serializeJson(messageDoc, message); + + // Push the message to the frontend + pushUpdateToFrontend(message); + + Serial.println("Bahn 2 automatisch auf 'Bereit' zurückgesetzt"); } } diff --git a/src/rfid.h b/src/rfid.h index 89c5837..5a62c8d 100644 --- a/src/rfid.h +++ b/src/rfid.h @@ -32,9 +32,6 @@ void setupRFID() { } - - - void handleAutomaticRFID() { if (!mfrc522.PICC_IsNewCardPresent()) { return; @@ -236,16 +233,9 @@ server.on("/api/users/insert", HTTP_POST, [](AsyncWebServerRequest *request) {}, request->send(200, "application/json", jsonString); }); - - - - - - } - // API Funktion: RFID Reader Status prüfen bool checkRFIDReaderStatus() { byte version = mfrc522.PCD_ReadRegister(mfrc522.VersionReg); diff --git a/src/wificlass.h b/src/wificlass.h index 83ba500..989b71c 100644 --- a/src/wificlass.h +++ b/src/wificlass.h @@ -16,7 +16,7 @@ const char* passwordAP = nullptr; char* ssidSTA = strdup("Obiwlankenobi"); char* passwordSTA = strdup("Delfine1!"); -PrettyOTA OTAUpdates; +PrettyOTA OTAUpdates; String getUniqueSSID();