diff --git a/html/spoolman.html b/html/spoolman.html index c9d08fd..d65b545 100644 --- a/html/spoolman.html +++ b/html/spoolman.html @@ -76,7 +76,7 @@ const code = document.getElementById('bambuCode').value; const autoSend = document.getElementById('autoSend').checked; - fetch(`/api/bambu?bambu_ip=${encodeURIComponent(ip)}&bambu_serialnr=${encodeURIComponent(serial)}&bambu_accesscode=${encodeURIComponent(code)}&autoSend=${autoSend}`) + 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) { @@ -122,13 +122,18 @@ -
- If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool. - - +
+

If activated, FilaMan will automatically update the next filled tray with the last scanned and weighed spool.

+
+ + +
+
+ +
- +

diff --git a/src/bambu.cpp b/src/bambu.cpp index 840d9f0..8ef7465 100644 --- a/src/bambu.cpp +++ b/src/bambu.cpp @@ -32,7 +32,7 @@ int ams_count = 0; String amsJsonData; // Speichert das fertige JSON für WebSocket-Clients AMSData ams_data[MAX_AMS]; // Definition des Arrays; -bool saveBambuCredentials(const String& ip, const String& serialnr, const String& accesscode, bool autoSend) { +bool saveBambuCredentials(const String& ip, const String& serialnr, const String& accesscode, bool autoSend, const String& autoSendTime) { if (BambuMqttTask) { vTaskDelete(BambuMqttTask); } @@ -42,6 +42,7 @@ bool saveBambuCredentials(const String& ip, const String& serialnr, const String doc["bambu_accesscode"] = accesscode; doc["bambu_serialnr"] = serialnr; doc["autoSendToBambu"] = autoSend; + doc["autoSendTime"] = (autoSendTime != "") ? autoSendTime.toInt() : autoSetBambuAmsCounter; if (!saveJsonValue("/bambu_credentials.json", doc)) { Serial.println("Fehler beim Speichern der Bambu-Credentials."); @@ -53,6 +54,7 @@ bool saveBambuCredentials(const String& ip, const String& serialnr, const String bambu_accesscode = accesscode.c_str(); bambu_serialnr = serialnr.c_str(); autoSendToBambu = autoSend; + autoSetBambuAmsCounter = autoSendTime.toInt(); vTaskDelay(100 / portTICK_PERIOD_MS); if (!setupMqtt()) return false; @@ -67,7 +69,8 @@ bool loadBambuCredentials() { String ip = doc["bambu_ip"].as(); String code = doc["bambu_accesscode"].as(); String serial = doc["bambu_serialnr"].as(); - autoSendToBambu = doc["autoSendToBambu"].as(); + if (doc["autoSendToBambu"].is()) autoSendToBambu = doc["autoSendToBambu"].as(); + if (doc["autoSendTime"].is()) autoSetBambuAmsCounter = doc["autoSendTime"].as(); ip.trim(); code.trim(); diff --git a/src/website.cpp b/src/website.cpp index ab96d78..ba29d10 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -286,17 +286,19 @@ void setupWebserver(AsyncWebServer &server) { String bambu_serialnr = request->getParam("bambu_serialnr")->value(); 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(); + autoSendTime.trim(); if (bambu_ip.length() == 0 || bambu_serialnr.length() == 0 || bambu_accesscode.length() == 0) { request->send(400, "application/json", "{\"success\": false, \"error\": \"Empty parameter\"}"); return; } - bool success = saveBambuCredentials(bambu_ip, bambu_serialnr, bambu_accesscode, autoSend); + bool success = saveBambuCredentials(bambu_ip, bambu_serialnr, bambu_accesscode, autoSend, autoSendTime); request->send(200, "application/json", "{\"healthy\": " + String(success ? "true" : "false") + "}"); });