fix: add remaining weight logging for PUT requests and improve error reporting in sendToApi function

This commit is contained in:
Manuel Weiser 2025-04-23 14:51:31 +02:00
parent e79c522e46
commit c78c20979d
2 changed files with 12 additions and 7 deletions

View File

@ -118,17 +118,19 @@ void sendToApi(void *parameter) {
Serial.print("Fehler beim Parsen der JSON-Antwort: ");
Serial.println(error.c_str());
} else {
float remaining_weight = doc["remaining_weight"].as<float>();
Serial.print("Aktuelles Gewicht: ");
Serial.println(remaining_weight);
oledShowMessage("Remaining: " + String(remaining_weight) + "g");
vTaskDelay(2000 / portTICK_PERIOD_MS);
if (httpType == "PUT") {
uint16_t remaining_weight = doc["remaining_weight"].as<float>();
Serial.print("Aktuelles Gewicht: ");
Serial.println(remaining_weight);
oledShowMessage("Remaining: " + String(remaining_weight) + "g");
}
vTaskDelay(3000 / portTICK_PERIOD_MS);
doc.clear();
}
} else {
Serial.println("Fehler beim Senden an Spoolman!");
Serial.println("Fehler beim Senden an Spoolman! HTTP Code: " + String(httpCode));
oledShowMessage("Spoolman update failed");
vTaskDelay(2000 / portTICK_PERIOD_MS);
}

View File

@ -674,6 +674,7 @@ bool setupMqtt() {
vTaskDelay(2000 / portTICK_PERIOD_MS);
connected = false;
oledShowTopRow();
autoSetToBambuSpoolId = 0;
}
if (!connected) return false;
@ -687,6 +688,8 @@ bool setupMqtt() {
}
void bambu_restart() {
Serial.println("Bambu restart");
if (BambuMqttTask) {
vTaskDelete(BambuMqttTask);
delay(10);