update navigation links, enhance NFC data display, and improve MQTT connection handling

This commit is contained in:
Manuel Weiser 2025-02-13 12:59:43 +01:00
parent be0a23e736
commit d46d5e14d2
6 changed files with 38 additions and 22 deletions

View File

@ -20,7 +20,7 @@
<a href="/">Start</a>
<a href="/waage">Scale</a>
<a href="/spoolman">Spoolman/Bambu</a>
<a href="/rfid">RFID</a>
<a href="/">About</a>
</nav>
<div class="status-container">
<div class="status-item">

View File

@ -448,7 +448,7 @@ function updateNfcData(data) {
// HTML für die Datenanzeige erstellen
let html = `
<div style="margin-top: 10px;">
<div class="nfc-card-data" style="margin-top: 10px;">
<p><strong>Brand:</strong> ${data.brand || 'N/A'}</p>
<p><strong>Type:</strong> ${data.type || 'N/A'} ${data.color_hex ? `<span style="
background-color: #${data.color_hex};

View File

@ -255,7 +255,7 @@ button:hover {
p {
font-size: 1rem;
color: #555;
color: #ffffff;
}
a {
@ -325,6 +325,13 @@ a:hover {
margin-top: 10px;
}
.nfc-card-data {
padding-left: 20px !important;
color: white !important;
font-weight: bold !important;
margin: 0 auto !important;
}
.nfc-success {
color: green;
}

View File

@ -422,9 +422,6 @@ void reconnect() {
}
void mqtt_loop(void * parameter) {
oledShowMessage("Bambu Connected");
bambu_connected = true;
oledShowTopRow();
for(;;) {
if (pauseBambuMqttTask) {
vTaskDelay(10000);
@ -452,13 +449,16 @@ bool setupMqtt() {
return false;
}
if (success && bambu_ip != "" && bambu_accesscode != "" && bambu_serialnr != "") {
if (success && bambu_ip != "" && bambu_accesscode != "" && bambu_serialnr != "")
{
sslClient.setCACert(root_ca);
sslClient.setInsecure();
client.setServer(bambu_ip, 8883);
// Verbinden mit dem MQTT-Server
if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode)) {
bool connected = true;
if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode))
{
client.setCallback(mqtt_callback);
client.setBufferSize(5120);
// Optional: Topic abonnieren
@ -467,24 +467,31 @@ bool setupMqtt() {
Serial.println("MQTT-Client initialisiert");
oledShowTopRow();
xTaskCreatePinnedToCore(
mqtt_loop, /* Function to implement the task */
"BambuMqtt", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
mqttTaskPrio, /* Priority of the task */
&BambuMqttTask, /* Task handle. */
mqttTaskCore); /* Core where the task should run */
} else {
oledShowMessage("Bambu Connected");
bambu_connected = true;
}
else
{
Serial.println("Fehler: Konnte sich nicht beim MQTT-Server anmelden");
oledShowMessage("Bambu Connection Failed");
oledShowTopRow();
vTaskDelay(2000 / portTICK_PERIOD_MS);
return false;
connected = false;
}
} else {
xTaskCreatePinnedToCore(
mqtt_loop, /* Function to implement the task */
"BambuMqtt", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
mqttTaskPrio, /* Priority of the task */
&BambuMqttTask, /* Task handle. */
mqttTaskCore); /* Core where the task should run */
if (!connected) return false;
}
else
{
Serial.println("Fehler: Keine MQTT-Daten vorhanden");
oledShowMessage("Bambu Credentials Missing");
oledShowTopRow();

View File

@ -379,6 +379,8 @@ void scanRfidTask(void * parameter) {
// Wenn geschrieben wird Schleife aussetzen
if (hasReadRfidTag != 3)
{
yield();
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength;

View File

@ -25,7 +25,7 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp
sendAmsData(client);
sendNfcData(client);
foundNfcTag(client, hasReadRfidTag);
sendWriteResult(client, 0);
sendWriteResult(client, 3);
} else if (type == WS_EVT_DISCONNECT) {
Serial.println("Client getrennt.");
} else if (type == WS_EVT_DATA) {