added auto-reconnect option to settings

This commit is contained in:
Tijn Kooijmans
2017-07-23 21:31:33 +02:00
parent 65d91f3908
commit 0d888bb101
2 changed files with 9 additions and 1 deletions

View File

@@ -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
View File

@@ -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);
}