diff --git a/src/bambu.cpp b/src/bambu.cpp index ad73bb7..3cf345e 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 = false; + bool connected = true; if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode)) { client.setCallback(mqtt_callback); @@ -476,15 +476,26 @@ bool setupMqtt() { oledShowMessage("Bambu Connected"); bambu_connected = true; oledShowTopRow(); + + 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 */ } else { Serial.println("Fehler: Konnte sich nicht beim MQTT-Server anmelden"); oledShowMessage("Bambu Connection Failed"); - oledShowTopRow(); vTaskDelay(2000 / portTICK_PERIOD_MS); - return false; + connected = false; + oledShowTopRow(); } + + if (!connected) return false; } else {