mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-08-02 20:25:10 +02:00
added auto-reconnect option to settings
This commit is contained in:
@@ -62,6 +62,7 @@ typedef struct mqtt_settings {
|
||||
uint32_t lwt_retain;
|
||||
uint32_t clean_session;
|
||||
uint32_t keepalive;
|
||||
bool auto_reconnect;
|
||||
} mqtt_settings;
|
||||
|
||||
typedef struct mqtt_event_data_t
|
||||
|
9
mqtt.c
9
mqtt.c
@@ -503,7 +503,11 @@ void mqtt_task(void *pvParameters)
|
||||
client->settings->disconnected_cb(client, NULL);
|
||||
}
|
||||
|
||||
continue;
|
||||
if (!client->settings->auto_reconnect) {
|
||||
break;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
mqtt_info("Connected to MQTT broker, create sending thread before call connected callback");
|
||||
xTaskCreate(&mqtt_sending_task, "mqtt_sending_task", 2048, client, CONFIG_MQTT_PRIORITY + 1, &xMqttSendingTask);
|
||||
@@ -520,6 +524,9 @@ void mqtt_task(void *pvParameters)
|
||||
}
|
||||
|
||||
vTaskDelete(xMqttSendingTask);
|
||||
if (!client->settings->auto_reconnect) {
|
||||
break;
|
||||
}
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user