Skip to content

Commit

Permalink
Fix compilation error in ESP32 Core v3.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Dec 5, 2024
1 parent c11afef commit 642395c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=ESP_SSLClient

version=2.1.12
version=2.1.13

author=Mobizt

Expand Down
4 changes: 2 additions & 2 deletions src/ESP_SSLClient.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
20 changes: 18 additions & 2 deletions src/client/BSSL_SSL_Client.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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))
Expand Down
20 changes: 18 additions & 2 deletions src/client/BSSL_SSL_Client.h
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/client/BSSL_TCP_Client.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/client/BSSL_TCP_Client.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 642395c

Please sign in to comment.