I found something similar for Arduino: https://github.com/khoih-prog/AsyncTCP_SSL. But, firstly, it's on Arduino and, secondly, the project is no longer maintained.
On the documentation page of ESP-IDF, I found only one related function - "esp_tls_plain_tcp_connect". But there are no examples. The only source code that uses this function is in the "components/tcp_transport/transport_ssl.c":
Code: Select all
static int tcp_connect(esp_transport_handle_t t, const char *host, int port, int timeout_ms)
{
transport_esp_tls_t *ssl = ssl_get_context_data(t);
esp_tls_last_error_t *err_handle = esp_transport_get_error_handle(t);
ssl->cfg.timeout_ms = timeout_ms;
esp_err_t err = esp_tls_plain_tcp_connect(host, strlen(host), port, &ssl->cfg, err_handle, &ssl->sockfd);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to open a new connection: %d", err);
err_handle->last_error = err;
ssl->sockfd = INVALID_SOCKET;
return -1;
}
return 0;
}