From 3590187cbe508baec9c1ca657d1884adfd075a56 Mon Sep 17 00:00:00 2001 From: tugsi Date: Sun, 30 Mar 2025 14:32:11 +0200 Subject: [PATCH] Added Fixed improve HTTP client configuration and clear update documents after API calls (Manuel Weiser) 6cc4efc - Fixes memory leak in HTTPClient by disabling connection reuse (Jan Philipp Ecker) update reload logic after removing and saving Bambu credentials for better cache handling (Manuel Weiser) Changed docs: update changelog and header for version v1.4.8 (Manuel Weiser) docs: update platformio.ini for version v1.4.8 (Manuel Weiser) Merge pull request #30 from janecker/main (ManuelW) Merge branch 'testing' into main (ManuelW) --- html/spoolman.html | 12 ++++++------ src/api.cpp | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/html/spoolman.html b/html/spoolman.html index dccfac5..b3ca686 100644 --- a/html/spoolman.html +++ b/html/spoolman.html @@ -70,9 +70,9 @@ document.getElementById('bambuStatusMessage').innerText = 'Bambu Credentials removed!'; // Reload with forced cache refresh after short delay setTimeout(() => { - window.location.replace('/'); - location.reload(true); - }, 1500); + window.location.reload(true); + window.location.href = '/'; + }, 1500); } else { document.getElementById('bambuStatusMessage').innerText = 'Error while removing Bambu Credentials.'; } @@ -116,9 +116,9 @@ document.getElementById('bambuStatusMessage').innerText = 'Bambu Credentials saved!'; // Reload with forced cache refresh after short delay setTimeout(() => { - window.location.replace('/'); - location.reload(true); - }, 1500); + window.location.reload(true); + window.location.href = '/'; + }, 1500); } else { document.getElementById('bambuStatusMessage').innerText = 'Error while saving Bambu Credentials.'; } diff --git a/src/api.cpp b/src/api.cpp index d15b273..486fdea 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -94,6 +94,7 @@ void sendToApi(void *parameter) { String octoToken = params->octoToken; HTTPClient http; + http.setReuse(false); http.begin(spoolsUrl); http.addHeader("Content-Type", "application/json"); if (octoEnabled && octoToken != "") http.addHeader("X-Api-Key", octoToken); @@ -111,6 +112,7 @@ void sendToApi(void *parameter) { } http.end(); + vTaskDelay(50 / portTICK_PERIOD_MS); // Speicher freigeben delete params; @@ -164,6 +166,7 @@ bool updateSpoolTagId(String uidString, const char* payload) { 0, // Priorität NULL // Task-Handle (nicht benötigt) ); + updateDoc.clear(); return true; } @@ -200,6 +203,7 @@ uint8_t updateSpoolWeight(String spoolId, uint16_t weight) { 0, // Priorität NULL // Task-Handle (nicht benötigt) ); + updateDoc.clear(); return 1; } @@ -237,6 +241,7 @@ bool updateSpoolOcto(int spoolId) { 0, // Priorität NULL // Task-Handle (nicht benötigt) ); + updateDoc.clear(); return true; }