From 642395c99ebd1e93b2b3db46fe828a06f74f826e Mon Sep 17 00:00:00 2001 From: Suwatchai K Date: Thu, 5 Dec 2024 12:02:41 +0700 Subject: [PATCH] Fix compilation error in ESP32 Core v3.1.x --- library.json | 2 +- library.properties | 2 +- src/ESP_SSLClient.h | 4 ++-- src/client/BSSL_SSL_Client.cpp | 20 ++++++++++++++++++-- src/client/BSSL_SSL_Client.h | 20 ++++++++++++++++++-- src/client/BSSL_TCP_Client.cpp | 4 ++-- src/client/BSSL_TCP_Client.h | 16 ++++++++-------- 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/library.json b/library.json index cce407a..95a5f07 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ESP_SSLClient", - "version": "2.1.12", + "version": "2.1.13", "keywords": "communication, REST, esp32, esp8266, arduino", "description": "This library provided the Secure Layer Networking (SSL/TLS) TCP Client for ESP8266, ESP32 and Raspberry Pi RP2040, Teensy, SAMD, AVR and other Arduino devices (except for avr) that support external networking interfaces e.g., WiFiClient, EthernetClient and GSMClient.", "repository": { diff --git a/library.properties b/library.properties index 54aa77e..97d9cad 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=ESP_SSLClient -version=2.1.12 +version=2.1.13 author=Mobizt diff --git a/src/ESP_SSLClient.h b/src/ESP_SSLClient.h index a97a6b3..76f23d9 100644 --- a/src/ESP_SSLClient.h +++ b/src/ESP_SSLClient.h @@ -1,8 +1,8 @@ /** * - * The ESP SSL Client Class, ESP_SSLClient.h v2.1.9 + * The ESP SSL Client Class, ESP_SSLClient.h v2.1.13 * - * Created June 27, 2024 + * Created November 5, 2024 * * The MIT License (MIT) * Copyright (c) 2023 K. Suwatchai (Mobizt) diff --git a/src/client/BSSL_SSL_Client.cpp b/src/client/BSSL_SSL_Client.cpp index 275d488..30ce2da 100644 --- a/src/client/BSSL_SSL_Client.cpp +++ b/src/client/BSSL_SSL_Client.cpp @@ -1,7 +1,7 @@ /** - * BSSL_SSL_Client library v1.0.17 for Arduino devices. + * BSSL_SSL_Client library v1.0.18 for Arduino devices. * - * Created October 29, 2024 + * Created November 5, 2024 * * This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab. * @@ -151,6 +151,22 @@ int BSSL_SSL_Client::connect(const char *host, uint16_t port) return 1; } +#if defined(ESP32_ARDUINO_CORE_CLIENT_CONNECT_HAS_TMO) +int BSSL_SSL_Client::connect(IPAddress ip, uint16_t port, int32_t timeout) +{ + if (timeout > 0) + setTimeout(timeout); + return connect(ip, port); +} + +int BSSL_SSL_Client::connect(const char *host, uint16_t port, int32_t timeout) +{ + if (timeout > 0) + setTimeout(timeout); + return connect(host, port); +} +#endif + uint8_t BSSL_SSL_Client::connected() { if (!mIsClientInitialized(false)) diff --git a/src/client/BSSL_SSL_Client.h b/src/client/BSSL_SSL_Client.h index 95b1652..6e3a35c 100644 --- a/src/client/BSSL_SSL_Client.h +++ b/src/client/BSSL_SSL_Client.h @@ -1,7 +1,7 @@ /** - * BSSL_SSL_Client library v1.0.17 for Arduino devices. + * BSSL_SSL_Client library v1.0.18 for Arduino devices. * - * Created October 29, 2024 + * Created November 5, 2024 * * This work contains codes based on WiFiClientSecure from Earle F. Philhower and SSLClient from OSU OPEnS Lab. * @@ -46,6 +46,17 @@ #define EMBED_SSL_ENGINE_BASE_OVERRIDE #endif +#if defined(ESP_ARDUINO_VERSION) /* ESP32 core >= v2.0.x */ +#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 1, 0) +#define ESP32_ARDUINO_CORE_CLIENT_CONNECT_OVERRRIDE override; +#define ESP32_ARDUINO_CORE_CLIENT_CONNECT_HAS_TMO +#else +#define ESP32_ARDUINO_CORE_CLIENT_CONNECT_OVERRRIDE +#endif +#else +#define ESP32_ARDUINO_CORE_CLIENT_CONNECT_OVERRRIDE +#endif + #define BSSL_SSL_CLIENT_MIN_SESSION_TIMEOUT_SEC 60 #if defined(USE_LIB_SSL_ENGINE) || defined(USE_EMBED_SSL_ENGINE) @@ -105,6 +116,11 @@ class BSSL_SSL_Client : public Client int connect(const char *host, uint16_t port) override; +#if defined(ESP32_ARDUINO_CORE_CLIENT_CONNECT_HAS_TMO) + int connect(IPAddress ip, uint16_t port, int32_t timeout) override; + int connect(const char *host, uint16_t port, int32_t timeout) override; +#endif + uint8_t connected() override; void validate(const char *host, uint16_t port); diff --git a/src/client/BSSL_TCP_Client.cpp b/src/client/BSSL_TCP_Client.cpp index a0b141d..52d035b 100644 --- a/src/client/BSSL_TCP_Client.cpp +++ b/src/client/BSSL_TCP_Client.cpp @@ -1,7 +1,7 @@ /** - * BSSL_TCP_Client v2.0.14 for Arduino devices. + * BSSL_TCP_Client v2.0.15 for Arduino devices. * - * Created June 27, 2024 + * Created November 5, 2024 * * The MIT License (MIT) * Copyright (c) 2023 K. Suwatchai (Mobizt) diff --git a/src/client/BSSL_TCP_Client.h b/src/client/BSSL_TCP_Client.h index c88ea94..419ee7c 100644 --- a/src/client/BSSL_TCP_Client.h +++ b/src/client/BSSL_TCP_Client.h @@ -1,7 +1,7 @@ /** - * BSSL_TCP_Client v2.0.14 for Arduino devices. + * BSSL_TCP_Client v2.0.15 for Arduino devices. * - * Created June 27, 2024 + * Created November 5, 2024 * * The MIT License (MIT) * Copyright (c) 2023 K. Suwatchai (Mobizt) @@ -108,7 +108,7 @@ class BSSL_TCP_Client : public Client * @param timeout The connection time out in miiliseconds. * @return 1 for success or 0 for error. */ - int connect(IPAddress ip, uint16_t port, int32_t timeout); + int connect(IPAddress ip, uint16_t port, int32_t timeout) ESP32_ARDUINO_CORE_CLIENT_CONNECT_OVERRRIDE; /** * Connect to server. @@ -125,7 +125,7 @@ class BSSL_TCP_Client : public Client * @param timeout The connection time out in miiliseconds. * @return 1 for success or 0 for error. */ - int connect(const char *host, uint16_t port, int32_t timeout); + int connect(const char *host, uint16_t port, int32_t timeout) ESP32_ARDUINO_CORE_CLIENT_CONNECT_OVERRRIDE; /** * Get TCP connection status. @@ -319,13 +319,13 @@ class BSSL_TCP_Client : public Client * Set the TCP session timeout in seconds. * * @param seconds The TCP session timeout in seconds. - * + * * The minimum session timeout value is 60 seconds. * Set 0 to disable session timed out. - * - * If There is no data to send (write) within this period, + * + * If There is no data to send (write) within this period, * the current connection will be closed and reconnect. - * + * * This requires when ESP32 WiFiClient was used. */ void setSessionTimeout(uint32_t seconds);