feat: erweitere Bambu-Credentials um AutoSend-Zeit und aktualisiere die Benutzeroberfläche

This commit is contained in:
Manuel Weiser 2025-02-25 12:17:20 +01:00
parent e4825d2905
commit a7b1721e1d
4 changed files with 13 additions and 4 deletions

View File

@ -75,8 +75,9 @@
const serial = document.getElementById('bambuSerial').value; const serial = document.getElementById('bambuSerial').value;
const code = document.getElementById('bambuCode').value; const code = document.getElementById('bambuCode').value;
const autoSend = document.getElementById('autoSend').checked; 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(response => response.json())
.then(data => { .then(data => {
if (data.healthy) { if (data.healthy) {

View File

@ -32,7 +32,7 @@ extern bool autoSendToBambu;
extern int autoSetToBambuSpoolId; extern int autoSetToBambuSpoolId;
bool loadBambuCredentials(); 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(); bool setupMqtt();
void mqtt_loop(void * parameter); void mqtt_loop(void * parameter);
bool setBambuSpool(String payload); bool setBambuSpool(String payload);

View File

@ -86,6 +86,12 @@ void sendUpdateProgress(int progress, const char* status = nullptr, const char*
} }
progressMsg += "}"; 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 // Sende die Nachricht mehrmals mit Verzögerung für wichtige Updates
if (status || abs(progress - lastSentProgress) >= 10 || progress == 100) { if (status || abs(progress - lastSentProgress) >= 10 || progress == 100) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
@ -148,7 +154,7 @@ void handleUpdate(AsyncWebServer &server) {
// Berechne den Fortschritt basierend auf dem Update-Typ // Berechne den Fortschritt basierend auf dem Update-Typ
if (isSpiffsUpdate) { if (isSpiffsUpdate) {
// SPIFFS: 5-75% für Upload // SPIFFS: 5-75% für Upload
currentProgress = 5 + (updateWritten * 100) / updateTotalSize; currentProgress = 6 + (updateWritten * 100) / updateTotalSize;
} else { } else {
// Firmware: 0-100% für Upload // Firmware: 0-100% für Upload
currentProgress = 1 + (updateWritten * 100) / updateTotalSize; currentProgress = 1 + (updateWritten * 100) / updateTotalSize;

View File

@ -247,6 +247,7 @@ void setupWebserver(AsyncWebServer &server) {
html.replace("{{bambuSerial}}", bambuSerial ? bambuSerial : ""); html.replace("{{bambuSerial}}", bambuSerial ? bambuSerial : "");
html.replace("{{bambuCode}}", bambuCode ? bambuCode : ""); html.replace("{{bambuCode}}", bambuCode ? bambuCode : "");
html.replace("{{autoSendToBambu}}", autoSendToBambu ? "checked" : ""); html.replace("{{autoSendToBambu}}", autoSendToBambu ? "checked" : "");
html.replace("{{autoSendTime}}", String(autoSetBambuAmsCounter));
} }
else else
{ {
@ -254,6 +255,7 @@ void setupWebserver(AsyncWebServer &server) {
html.replace("{{bambuSerial}}", ""); html.replace("{{bambuSerial}}", "");
html.replace("{{bambuCode}}", ""); html.replace("{{bambuCode}}", "");
html.replace("{{autoSendToBambu}}", ""); html.replace("{{autoSendToBambu}}", "");
html.replace("{{autoSendTime}}", String(autoSetBambuAmsCounter));
} }
request->send(200, "text/html", html); request->send(200, "text/html", html);
@ -287,7 +289,7 @@ void setupWebserver(AsyncWebServer &server) {
String bambu_accesscode = request->getParam("bambu_accesscode")->value(); String bambu_accesscode = request->getParam("bambu_accesscode")->value();
bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false; bool autoSend = (request->getParam("autoSend")->value() == "true") ? true : false;
String autoSendTime = request->getParam("autoSendTime")->value(); String autoSendTime = request->getParam("autoSendTime")->value();
Serial.println(autoSend);
bambu_ip.trim(); bambu_ip.trim();
bambu_serialnr.trim(); bambu_serialnr.trim();
bambu_accesscode.trim(); bambu_accesscode.trim();