forked from espressif/esp-mqtt
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 lwt_retain;
|
||||||
uint32_t clean_session;
|
uint32_t clean_session;
|
||||||
uint32_t keepalive;
|
uint32_t keepalive;
|
||||||
|
bool auto_reconnect;
|
||||||
} mqtt_settings;
|
} mqtt_settings;
|
||||||
|
|
||||||
typedef struct mqtt_event_data_t
|
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);
|
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");
|
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);
|
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);
|
vTaskDelete(xMqttSendingTask);
|
||||||
|
if (!client->settings->auto_reconnect) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user