Modify esp-tls and tcp_transport to support keep alive for tcp and ssl connection

Closes IDFGH-4543
This commit is contained in:
yuanjm
2021-01-06 16:58:39 +08:00
committed by bot
parent cf9ac2ef9e
commit 044c3e3e74
8 changed files with 124 additions and 1 deletions

View File

@@ -16,11 +16,21 @@
#define _ESP_TRANSPORT_H_
#include <esp_err.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Keep alive parameters structure
*/
typedef struct esp_transport_keepalive {
bool keep_alive_enable; /*!< Enable keep-alive timeout */
int keep_alive_idle; /*!< Keep-alive idle time (second) */
int keep_alive_interval; /*!< Keep-alive interval time (second) */
int keep_alive_count; /*!< Keep-alive packet retry send count */
} esp_transport_keep_alive_t;
typedef struct esp_transport_internal* esp_transport_list_handle_t;
typedef struct esp_transport_item_t* esp_transport_handle_t;

View File

@@ -165,6 +165,14 @@ void esp_transport_ssl_set_ds_data(esp_transport_handle_t t, void *ds_data);
*/
void esp_transport_ssl_set_psk_key_hint(esp_transport_handle_t t, const psk_hint_key_t* psk_hint_key);
/**
* @brief Set keep-alive status in current ssl context
*
* @param[in] t ssl transport
* @param[in] keep_alive_cfg The handle for keep-alive configuration
*/
void esp_transport_ssl_set_keep_alive(esp_transport_handle_t t, esp_transport_keep_alive_t *keep_alive_cfg);
#ifdef __cplusplus
}
#endif

View File

@@ -21,6 +21,15 @@
extern "C" {
#endif
/**
* @brief Set TCP keep-alive configuration
*
* @param[in] t The transport handle
* @param[in] keep_alive_cfg The keep-alive config
*
*/
void esp_transport_tcp_set_keep_alive(esp_transport_handle_t t, esp_transport_keep_alive_t *keep_alive_cfg);
/**
* @brief Create TCP transport, the transport handle must be release esp_transport_destroy callback
*