fix: update MQTT connection logic to ensure proper task creation and connection handling
This commit is contained in:
parent
a05cde8669
commit
49f36bb25b
@ -463,7 +463,7 @@ bool setupMqtt() {
|
|||||||
client.setServer(bambu_ip, 8883);
|
client.setServer(bambu_ip, 8883);
|
||||||
|
|
||||||
// Verbinden mit dem MQTT-Server
|
// Verbinden mit dem MQTT-Server
|
||||||
bool connected = false;
|
bool connected = true;
|
||||||
if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode))
|
if (client.connect(bambu_serialnr, bambu_username, bambu_accesscode))
|
||||||
{
|
{
|
||||||
client.setCallback(mqtt_callback);
|
client.setCallback(mqtt_callback);
|
||||||
@ -476,15 +476,26 @@ bool setupMqtt() {
|
|||||||
oledShowMessage("Bambu Connected");
|
oledShowMessage("Bambu Connected");
|
||||||
bambu_connected = true;
|
bambu_connected = true;
|
||||||
oledShowTopRow();
|
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
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Fehler: Konnte sich nicht beim MQTT-Server anmelden");
|
Serial.println("Fehler: Konnte sich nicht beim MQTT-Server anmelden");
|
||||||
oledShowMessage("Bambu Connection Failed");
|
oledShowMessage("Bambu Connection Failed");
|
||||||
oledShowTopRow();
|
|
||||||
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
||||||
return false;
|
connected = false;
|
||||||
|
oledShowTopRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!connected) return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user