diff --git a/html/spoolman.html b/html/spoolman.html index d65b545..9b2bcca 100644 --- a/html/spoolman.html +++ b/html/spoolman.html @@ -75,8 +75,9 @@ const serial = document.getElementById('bambuSerial').value; const code = document.getElementById('bambuCode').value; const autoSend = document.getElementById('autoSend').checked; + const autoSendTime = document.getElementById('autoSendTime').value; - fetch(`/api/bambu?bambu_ip=${encodeURIComponent(ip)}&bambu_serialnr=${encodeURIComponent(serial)}&bambu_accesscode=${encodeURIComponent(code)}&autoSend=${autoSend}$autoSendTime=${autoSendTime}`) + fetch(`/api/bambu?bambu_ip=${encodeURIComponent(ip)}&bambu_serialnr=${encodeURIComponent(serial)}&bambu_accesscode=${encodeURIComponent(code)}&autoSend=${autoSend}&autoSendTime=${autoSendTime}`) .then(response => response.json()) .then(data => { if (data.healthy) { diff --git a/src/bambu.h b/src/bambu.h index 61f68fa..1dc7b3d 100644 --- a/src/bambu.h +++ b/src/bambu.h @@ -32,7 +32,7 @@ extern bool autoSendToBambu; extern int autoSetToBambuSpoolId; bool loadBambuCredentials(); -bool saveBambuCredentials(const String& bambu_ip, const String& bambu_serialnr, const String& bambu_accesscode, const bool autoSend); +bool saveBambuCredentials(const String& bambu_ip, const String& bambu_serialnr, const String& bambu_accesscode, const bool autoSend, const String& autoSendTime); bool setupMqtt(); void mqtt_loop(void * parameter); bool setBambuSpool(String payload); diff --git a/src/ota.cpp b/src/ota.cpp index 96332b4..228602e 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -86,6 +86,12 @@ void sendUpdateProgress(int progress, const char* status = nullptr, const char* } progressMsg += "}"; + if (progress == 100) { + // Sende die Nachricht nur einmal für den Abschluss + ws.textAll("{\"type\":\"updateProgress\",\"progress\":100,\"status\":\"success\",\"message\":\"Update successful! Restarting device...\"}"); + delay(50); + } + // Sende die Nachricht mehrmals mit Verzögerung für wichtige Updates if (status || abs(progress - lastSentProgress) >= 10 || progress == 100) { for (int i = 0; i < 2; i++) { @@ -148,7 +154,7 @@ void handleUpdate(AsyncWebServer &server) { // Berechne den Fortschritt basierend auf dem Update-Typ if (isSpiffsUpdate) { // SPIFFS: 5-75% für Upload - currentProgress = 5 + (updateWritten * 100) / updateTotalSize; + currentProgress = 6 + (updateWritten * 100) / updateTotalSize; } else { // Firmware: 0-100% für Upload currentProgress = 1 + (updateWritten * 100) / updateTotalSize; diff --git a/src/website.cpp b/src/website.cpp index ba29d10..296bdaa 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -247,6 +247,7 @@ void setupWebserver(AsyncWebServer &server) { html.replace("{{bambuSerial}}", bambuSerial ? bambuSerial : ""); html.replace("{{bambuCode}}", bambuCode ? bambuCode : ""); html.replace("{{autoSendToBambu}}", autoSendToBambu ? "checked" : ""); + html.replace("{{autoSendTime}}", String(autoSetBambuAmsCounter)); } else { @@ -254,6 +255,7 @@ void setupWebserver(AsyncWebServer &server) { html.replace("{{bambuSerial}}", ""); html.replace("{{bambuCode}}", ""); html.replace("{{autoSendToBambu}}", ""); + html.replace("{{autoSendTime}}", String(autoSetBambuAmsCounter)); } request->send(200, "text/html", html); @@ -287,7 +289,7 @@ void setupWebserver(AsyncWebServer &server) { String bambu_accesscode = request->getParam("bambu_accesscode")->value(); bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false; String autoSendTime = request->getParam("autoSendTime")->value(); - Serial.println(autoSend); + bambu_ip.trim(); bambu_serialnr.trim(); bambu_accesscode.trim();