Merge pull request #1485 from No-Signal/bugfix/mqtt_loop_fix

Fixing mqtt_loop setup regression bug
This commit is contained in:
Daniel Öster 2025-09-04 15:05:25 +03:00 committed by GitHub
commit 2ef8055535
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 14 deletions

View file

@ -474,6 +474,18 @@ void core_loop(void*) {
}
}
void mqtt_loop(void*) {
esp_task_wdt_add(NULL); // Register this task with WDT
while (true) {
START_TIME_MEASUREMENT(mqtt);
mqtt_client_loop();
END_TIME_MEASUREMENT_MAX(mqtt, datalayer.system.status.mqtt_task_10s_max_us);
esp_task_wdt_reset(); // Reset watchdog
delay(1);
}
}
// Initialization
void setup() {
init_hal();
@ -573,15 +585,3 @@ void setup() {
// Loop empty, all functionality runs in tasks
void loop() {}
void mqtt_loop(void*) {
esp_task_wdt_add(NULL); // Register this task with WDT
while (true) {
START_TIME_MEASUREMENT(mqtt);
mqtt_loop();
END_TIME_MEASUREMENT_MAX(mqtt, datalayer.system.status.mqtt_task_10s_max_us);
esp_task_wdt_reset(); // Reset watchdog
delay(1);
}
}

View file

@ -675,7 +675,7 @@ bool init_mqtt(void) {
return true;
}
void mqtt_loop(void) {
void mqtt_client_loop(void) {
// Only attempt to publish/reconnect MQTT if Wi-Fi is connectedand checkTimmer is elapsed
if (check_global_timer.elapsed() && WiFi.status() == WL_CONNECTED) {

View file

@ -58,7 +58,7 @@ extern const char* ha_device_id;
extern char mqtt_msg[MQTT_MSG_BUFFER_SIZE];
bool init_mqtt(void);
void mqtt_loop(void);
void mqtt_client_loop(void);
bool mqtt_publish(const char* topic, const char* mqtt_msg, bool retain);
#endif