Преглед изворни кода

esp-tls: mark esp_tls_conn_delete API as deprecated

It is recommended to use `esp_tls_conn_destroy` API instead
Mahavir Jain пре 4 година
родитељ
комит
c26500cd5a

+ 4 - 9
components/esp-tls/esp_tls.c

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -92,11 +92,6 @@ static ssize_t tcp_write(esp_tls_t *tls, const char *data, size_t datalen)
 /**
  * @brief      Close the TLS connection and free any allocated resources.
  */
-void esp_tls_conn_delete(esp_tls_t *tls)
-{
-    esp_tls_conn_destroy(tls);
-}
-
 int esp_tls_conn_destroy(esp_tls_t *tls)
 {
     if (tls != NULL) {
@@ -463,14 +458,14 @@ esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const e
         if (ret == 1) {
             return tls;
         } else if (ret == -1) {
-            esp_tls_conn_delete(tls);
+            esp_tls_conn_destroy(tls);
             ESP_LOGE(TAG, "Failed to open new connection");
             return NULL;
         } else if (ret == 0 && cfg->timeout_ms >= 0) {
             size_t timeout_ticks = pdMS_TO_TICKS(cfg->timeout_ms);
             uint32_t expired = xTaskGetTickCount() - start;
             if (expired >= timeout_ticks) {
-                esp_tls_conn_delete(tls);
+                esp_tls_conn_destroy(tls);
                 ESP_LOGE(TAG, "Failed to open new connection in specified timeout");
                 return NULL;
             }
@@ -544,7 +539,7 @@ esp_tls_t *esp_tls_conn_http_new(const char *url, const esp_tls_cfg_t *cfg)
                               get_port(url, &u), cfg, tls) == 1) {
         return tls;
     }
-    esp_tls_conn_delete(tls);
+    esp_tls_conn_destroy(tls);
     return NULL;
 }
 

+ 2 - 4
components/esp-tls/esp_tls.h

@@ -1,5 +1,5 @@
 /*
- * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
@@ -499,11 +499,9 @@ static inline ssize_t esp_tls_conn_read(esp_tls_t *tls, void  *data, size_t data
 /**
  * @brief      Compatible version of esp_tls_conn_destroy() to close the TLS/SSL connection
  *
- * @note This API will be removed in IDFv5.0
- *
  * @param[in]  tls  pointer to esp-tls as esp-tls handle.
  */
-void esp_tls_conn_delete(esp_tls_t *tls);
+void esp_tls_conn_delete(esp_tls_t *tls) __attribute__((deprecated("Please use esp_tls_conn_destroy() instead")));
 
 /**
  * @brief      Close the TLS/SSL connection and free any allocated resources.

+ 1 - 1
docs/en/api-reference/protocols/esp_tls.rst

@@ -11,7 +11,7 @@ All the configuration can be specified in the ``esp_tls_cfg_t`` data structure.
     * :cpp:func:`esp_tls_conn_new`: for opening a new TLS connection.
     * :cpp:func:`esp_tls_conn_read`: for reading from the connection.
     * :cpp:func:`esp_tls_conn_write`: for writing into the connection.
-    * :cpp:func:`esp_tls_conn_delete`: for freeing up the connection.
+    * :cpp:func:`esp_tls_conn_destroy`: for freeing up the connection.
 
 Any application layer protocol like HTTP1, HTTP2 etc can be executed on top of this layer.
 

+ 6 - 14
examples/protocols/http2_request/components/sh2lib/sh2lib.c

@@ -1,16 +1,8 @@
-// Copyright 2017 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 #include <stdlib.h>
 #include <stdint.h>
 #include <stddef.h>
@@ -280,7 +272,7 @@ void sh2lib_free(struct sh2lib_handle *hd)
         hd->http2_sess = NULL;
     }
     if (hd->http2_tls) {
-	esp_tls_conn_delete(hd->http2_tls);
+	esp_tls_conn_destroy(hd->http2_tls);
         hd->http2_tls = NULL;
     }
     if (hd->hostname) {

+ 1 - 1
examples/protocols/https_request/main/https_request_example_main.c

@@ -159,7 +159,7 @@ static void https_get_request(esp_tls_cfg_t cfg, const char *WEB_SERVER_URL, con
     } while (1);
 
 exit:
-    esp_tls_conn_delete(tls);
+    esp_tls_conn_destroy(tls);
     for (int countdown = 10; countdown >= 0; countdown--) {
         ESP_LOGI(TAG, "%d...", countdown);
         vTaskDelay(1000 / portTICK_PERIOD_MS);

+ 1 - 1
examples/protocols/https_x509_bundle/main/https_x509_bundle_example_main.c

@@ -72,7 +72,7 @@ static void https_get_task(void *pvParameters)
                 ESP_LOGE(TAG, "Could not connect to %s", web_urls[i]);
             }
 
-            esp_tls_conn_delete(tls);
+            esp_tls_conn_destroy(tls);
             vTaskDelay(1000 / portTICK_PERIOD_MS);
         }
 

+ 0 - 1
tools/ci/check_copyright_ignore.txt

@@ -2729,7 +2729,6 @@ examples/protocols/esp_local_ctrl/main/app_main.c
 examples/protocols/esp_local_ctrl/main/esp_local_ctrl_service.c
 examples/protocols/esp_local_ctrl/scripts/esp_local_ctrl.py
 examples/protocols/esp_local_ctrl/scripts/proto_lc.py
-examples/protocols/http2_request/components/sh2lib/sh2lib.c
 examples/protocols/http2_request/components/sh2lib/sh2lib.h
 examples/protocols/http2_request/main/http2_request_example_main.c
 examples/protocols/http_request/main/http_request_example_main.c