diff --git a/README.md b/README.md index 8ff586e..9828c2f 100644 --- a/README.md +++ b/README.md @@ -61,11 +61,18 @@ This library is fully compatible and able to work with [ESP-Mail-Client](https:/ ## Basic Usage ```cpp #include - #if defined(ESP32) || defined(PICO_RP2040) + #if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W) #include #elif defined(ESP8266) #include + #elif __has_include() + #include + #elif __has_include() + #include + #elif __has_include() + #include #endif + #include ESP_SSLClient ssl_client; diff --git a/examples/gsm/gsm.ino b/examples/gsm/gsm.ino index fc553b8..f346b25 100644 --- a/examples/gsm/gsm.ino +++ b/examples/gsm/gsm.ino @@ -38,7 +38,6 @@ const char apn[] = "YourAPN"; const char gprsUser[] = ""; const char gprsPass[] = ""; - #include #include @@ -124,24 +123,6 @@ void setup() DBG(" setNetworkMode faill"); return; } - - // ignore server ssl certificate verification - ssl_client.setInsecure(); - - // Set the receive and transmit buffers size in bytes for memory allocation (512 to 16384). - ssl_client.setBufferSizes(1024 /* rx */, 512 /* tx */); - - /** Call setDebugLevel(level) to set the debug - * esp_ssl_debug_none = 0 - * esp_ssl_debug_error = 1 - * esp_ssl_debug_warn = 2 - * esp_ssl_debug_info = 3 - * esp_ssl_debug_dump = 4 - */ - ssl_client.setDebugLevel(1); - - // assign the basic client - ssl_client.setClient(&basic_client); } void loop() @@ -217,6 +198,24 @@ void loop() } #endif + // ignore server ssl certificate verification + ssl_client.setInsecure(); + + // Set the receive and transmit buffers size in bytes for memory allocation (512 to 16384). + ssl_client.setBufferSizes(1024 /* rx */, 512 /* tx */); + + /** Call setDebugLevel(level) to set the debug + * esp_ssl_debug_none = 0 + * esp_ssl_debug_error = 1 + * esp_ssl_debug_warn = 2 + * esp_ssl_debug_info = 3 + * esp_ssl_debug_dump = 4 + */ + ssl_client.setDebugLevel(1); + + // assign the basic client + ssl_client.setClient(&basic_client); + Serial.println("---------------------------------"); Serial.print("Connecting to server..."); diff --git a/library.json b/library.json index dae5fbe..ef02dce 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ESP_SSLClient", - "version": "2.1.3", + "version": "2.1.4", "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 38f8e5c..c8b01bc 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=ESP_SSLClient -version=2.1.3 +version=2.1.4 author=Mobizt diff --git a/src/ESP_SSLClient.h b/src/ESP_SSLClient.h index 3678750..6a5fc5d 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.3 + * The ESP SSL Client Class, ESP_SSLClient.h v2.1.4 * - * Created August 13, 2023 + * Created August 16, 2023 * * The MIT License (MIT) * Copyright (c) 2023 K. Suwatchai (Mobizt) @@ -38,13 +38,42 @@ #if defined(USE_EMBED_SSL_ENGINE) || defined(USE_LIB_SSL_ENGINE) #include "client/BSSL_TCP_Client.h" class ESP_SSLClient : public BSSL_TCP_Client +{ +public: + ESP_SSLClient(){}; + ~ESP_SSLClient(){}; +}; + +class ESP_SSLClient2 : public BSSL_TCP_Client +{ +public: + ESP_SSLClient2(Client &client, bool enableSSL = true) : _base_client(client) + { + setClient(&_base_client, enableSSL); + }; + ~ESP_SSLClient2(){}; + +private: + Client &_base_client; +}; + #else class ESP_SSLClient -#endif { public: ESP_SSLClient(){}; ~ESP_SSLClient(){}; }; -#endif \ No newline at end of file +class ESP_SSLClient2 +{ +public: + ESP_SSLClient2(Client &client, bool enableSSL = true) : _base_client(client){}; + ~ESP_SSLClient2(){}; + +private: + Client &_base_client; +}; +#endif + +#endif