mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-29 18:28:24 +02:00
Merge branch 'feature/tcp_keepalive' into 'master'
feat: Add TCP keepalive configuration Closes IDF-8049 See merge request espressif/esp-mqtt!220
This commit is contained in:
@ -429,6 +429,10 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
|
||||
client->config->port = config->broker.address.port;
|
||||
}
|
||||
|
||||
if (config->network.tcp_keep_alive_cfg.keep_alive_enable) {
|
||||
client->config->tcp_keep_alive_cfg = config->network.tcp_keep_alive_cfg;
|
||||
}
|
||||
|
||||
err = ESP_ERR_NO_MEM;
|
||||
ESP_MEM_CHECK(TAG, esp_mqtt_set_if_config(config->broker.address.hostname, &client->config->host), goto _mqtt_set_config_failed);
|
||||
ESP_MEM_CHECK(TAG, esp_mqtt_set_if_config(config->broker.address.path, &client->config->path), goto _mqtt_set_config_failed);
|
||||
@ -1627,6 +1631,10 @@ static void esp_mqtt_task(void *pv)
|
||||
esp_mqtt_set_ssl_transport_properties(client->transport_list, client->config);
|
||||
#endif
|
||||
|
||||
if(client->config->tcp_keep_alive_cfg.keep_alive_enable) {
|
||||
esp_transport_tcp_set_keep_alive(client->transport, &client->config->tcp_keep_alive_cfg);
|
||||
}
|
||||
|
||||
client->event.event_id = MQTT_EVENT_BEFORE_CONNECT;
|
||||
esp_mqtt_dispatch_event_with_msgid(client);
|
||||
|
||||
|
Reference in New Issue
Block a user