sh2lib: Update deprecated esp_tls API

This commit is contained in:
Laukik Hase 2022-04-04 12:02:15 +05:30
parent e3f56d39f4
commit 6737dc5458
No known key found for this signature in database
GPG Key ID: 11C571361F51A199
2 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,4 @@
version: "1.0.1"
version: "1.0.2"
description: HTTP2 TLS Abstraction Layer
url: https://github.com/espressif/idf-extra-components/tree/master/sh2lib
dependencies:

View File

@ -246,10 +246,23 @@ int sh2lib_connect(struct sh2lib_config_t *cfg, struct sh2lib_handle *hd)
.non_block = true,
.timeout_ms = 10 * 1000,
};
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
hd->http2_tls = esp_tls_init();
if (!hd->http2_tls) {
ESP_LOGE(TAG, "Failed to allocate esp_tls handle!");
goto error;
}
// NOTE: This API is an alternative to previous `esp_tls_conn_http_new` from ESP-IDF v5.0 onwards.
if (esp_tls_conn_http_new_sync(cfg->uri, &tls_cfg, hd->http2_tls) != 1) {
#else
if ((hd->http2_tls = esp_tls_conn_http_new(cfg->uri, &tls_cfg)) == NULL) {
#endif
ESP_LOGE(TAG, "[sh2-connect] esp-tls connection failed");
goto error;
}
struct http_parser_url u;
http_parser_url_init(&u);
http_parser_parse_url(cfg->uri, strlen(cfg->uri), 0, &u);