From 64e5a171b681c9e012b81ec41d8a9f14b71cdff8 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Fri, 14 Feb 2025 16:01:56 +0100 Subject: [PATCH] fix: update MQTT connection logic to handle failures correctly and not try to connect random --- src/bambu.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/bambu.cpp b/src/bambu.cpp index 6a8ce6e..ad73bb7 100644 --- a/src/bambu.cpp +++ b/src/bambu.cpp @@ -463,7 +463,7 @@ bool setupMqtt() { client.setServer(bambu_ip, 8883); // Verbinden mit dem MQTT-Server - bool connected = true; + bool connected = false; if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode)) { client.setCallback(mqtt_callback); @@ -473,7 +473,6 @@ bool setupMqtt() { //client.subscribe(request_topic.c_str()); Serial.println("MQTT-Client initialisiert"); - oledShowTopRow(); oledShowMessage("Bambu Connected"); bambu_connected = true; oledShowTopRow(); @@ -484,19 +483,8 @@ bool setupMqtt() { oledShowMessage("Bambu Connection Failed"); oledShowTopRow(); vTaskDelay(2000 / portTICK_PERIOD_MS); - connected = false; + return false; } - - xTaskCreatePinnedToCore( - mqtt_loop, /* Function to implement the task */ - "BambuMqtt", /* Name of the task */ - 10000, /* Stack size in words */ - NULL, /* Task input parameter */ - mqttTaskPrio, /* Priority of the task */ - &BambuMqttTask, /* Task handle. */ - mqttTaskCore); /* Core where the task should run */ - - if (!connected) return false; } else {