diff --git a/.github/workflows/arduino_examples.yml b/.github/workflows/arduino_examples.yml index 46ca279..856bf2f 100644 --- a/.github/workflows/arduino_examples.yml +++ b/.github/workflows/arduino_examples.yml @@ -34,7 +34,7 @@ jobs: - name: Install specific branch of GovoroxSSLClient run: | mkdir -p ~/Arduino/libraries - git clone --branch v1.3.0 https://github.com/govorox/SSLClient.git ~/Arduino/libraries/GovoroxSSLClient + git clone --branch 95-release-130-fails-to-compile-on-arduino-esp32-v3 https://github.com/govorox/SSLClient.git ~/Arduino/libraries/GovoroxSSLClient - name: Install other libs run: | @@ -46,9 +46,9 @@ jobs: - name: Compile Examples for Arduino-ESP32@2.0.17 run: | arduino-cli core install esp32:esp32@2.0.17 - ./.github/workflows/scripts/compile_arduino_examples.sh --clean + ./scripts/compile_arduino_examples.sh --clean - # - name: Compile Examples for Arduino-ESP32@3.0.2 - # run: | - # arduino-cli core install esp32:esp32@3.0.2 - # ./.github/workflows/scripts/compile_arduino_examples.sh --clean + - name: Compile Examples for Arduino-ESP32@3.0.2 + run: | + arduino-cli core install esp32:esp32@3.0.2 + ./scripts/compile_arduino_examples.sh --clean diff --git a/.github/workflows/pio_examples.yml b/.github/workflows/pio_examples.yml index 6d04a58..abe62d6 100644 --- a/.github/workflows/pio_examples.yml +++ b/.github/workflows/pio_examples.yml @@ -27,4 +27,4 @@ jobs: - name: Compile Examples run: | - ./.github/workflows/scripts/compile_pio_examples.sh --clean + ./scripts/compile_pio_examples.sh --clean diff --git a/.github/workflows/scripts/install_sslclient_for_testing.sh b/.github/workflows/scripts/install_sslclient_for_testing.sh deleted file mode 100755 index ee7443f..0000000 --- a/.github/workflows/scripts/install_sslclient_for_testing.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/bash - -rm -rf ~/SSLClient -git clone https://github.com/govorox/SSLClient.git ~/SSLClient -cd ~/SSLClient -git checkout v1.3.0 -mkdir -p SSLClient -mv LICENSE library.properties src SSLClient/ -zip -r SSLClient.zip SSLClient -mkdir -p ~/.arduino15 -echo -e "library:\n enable_unsafe_install: true" > ~/.arduino15/arduino-cli.yaml -arduino-cli lib install --config-file ~/.arduino15/arduino-cli.yaml --zip-path SSLClient.zip diff --git a/.gitignore b/.gitignore index 737c6d0..e733fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ lib/* test.log emulation.log -compile_errors.log \ No newline at end of file +compile_errors.log +compile_output.txt \ No newline at end of file diff --git a/README.md b/README.md index 7b67f70..f1f5d91 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ *Install via the Arduino IDE or PlatformIO:* -**Arduino IDE** - search for `GovoroxSSLClient` inthe library manager (for now, ensure esp32 boards are installed to version `2.0.17` and no higher) +**Arduino IDE** - search for `GovoroxSSLClient` in the library manager. -**PlatformIO** - add `digitaldragon/SSLClient@^1.3.0` to `platformio.ini` +**PlatformIO** - add `digitaldragon/SSLClient@^1.3.1` to `platformio.ini`. ## 🚀 Overview @@ -45,6 +45,8 @@ Originally based on the `WiFiClientSecure` for Arduino-ESP32 the SSLClient exten ## 🌟 What's New in the Latest Release +- **Examples for PlatformIO and Arduino IDE**: Updated examples to work with both PlatformIO and Arduino IDE for both Arduino-ESP32@2.0.17 and Arduino-ESP32@>3.0.0. + - **Major Versions 2 and 3 of MBedTLS**: Updated to support the latest version of the MBedTLS library. - **Feature flag for compatibility with MbedTLS v3.x.x** - Automated by `MBEDTLS_VERSION_MAJOR`. @@ -63,8 +65,6 @@ Originally based on the `WiFiClientSecure` for Arduino-ESP32 the SSLClient exten - **Add GitHub Actions workflow** to ensure Arduino IDE compile. -- **Fix Arduino IDE examples to compile** when using `arduino-esp32@2.0.17` - This is still broken for `@3.0.2`. There is a breaking change in `arduino-esp32` from `v3.0.0` which is causing ambiguous reference errors to byte. - ## ✨ Features - Secure TLS communication. diff --git a/examples/Esp32-Arduino-IDE/https_eth_LilyGo-T-ETH-POE/https_eth_LilyGo-T-ETH-POE.ino b/examples/Esp32-Arduino-IDE/https_eth_LilyGo-T-ETH-POE/https_eth_LilyGo-T-ETH-POE.ino index 225d292..4d2e6a0 100644 --- a/examples/Esp32-Arduino-IDE/https_eth_LilyGo-T-ETH-POE/https_eth_LilyGo-T-ETH-POE.ino +++ b/examples/Esp32-Arduino-IDE/https_eth_LilyGo-T-ETH-POE/https_eth_LilyGo-T-ETH-POE.ino @@ -3,52 +3,70 @@ * ESP32 LilyGo-T-ETH-POE Example * * HTTPS (TLS/SLL) with CA Certificate via "ETH.h" - * This example use the WiFiClient class to integrate ETH functionality + * This example uses the WiFiClient class to integrate ETH functionality * * About board: https://github.com/Xinyuan-LilyGO/LilyGO-T-ETH-POE * Base example: https://github.com/Xinyuan-LilyGO/LilyGO-T-ETH-POE/blob/master/example/eth/eth.ino * **************************************************************/ +// To make HTTP request easy: https://github.com/arduino-libraries/ArduinoHttpClient +#include #include #include "WiFi.h" #include "SSLClient.h" -//To make http request esay: https://github.com/arduino-libraries/ArduinoHttpClient -#include -//Please enter your CA certificate in ca_cert.h +// Please enter your CA certificate in ca_cert.h #include "ca_cert.h" -//ESP32 LilyGo-T-ETH-POE Board Ethernet pins definition +// ESP32 LilyGo-T-ETH-POE Board Ethernet pins definition #define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT #define ETH_POWER_PIN -1 #define ETH_TYPE ETH_PHY_LAN8720 -#define ETH_ADDR 0 +#define ETH_ADDR 1 // Update this according to the required value for v3.x.x and 0 for v2.x.x #define ETH_MDC_PIN 23 #define ETH_MDIO_PIN 18 const char hostname[] = "www.howsmyssl.com"; int port = 443; -//Layers stack -WiFiClient eth_transpor_layer; -SSLClient secure_presentation_layer(ð_transpor_layer); +// Layers stack +WiFiClient eth_transport_layer; +SSLClient secure_presentation_layer(ð_transport_layer); HttpClient http_client = HttpClient(secure_presentation_layer, hostname, port); static bool eth_connected = false; -//Ethernet events +// Ethernet events +#if ESP_ARDUINO_VERSION_MAJOR >= 3 +void ETHEvent(WiFiEvent_t event, WiFiEventInfo_t info) +#else void ETHEvent(WiFiEvent_t event) +#endif { switch (event) { + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + case ARDUINO_EVENT_ETH_START: + #else case SYSTEM_EVENT_ETH_START: + #endif Serial.println("ETH Started"); ETH.setHostname("esp32-ethernet"); break; + + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + case ARDUINO_EVENT_ETH_CONNECTED: + #else case SYSTEM_EVENT_ETH_CONNECTED: + #endif Serial.println("ETH Connected"); break; + + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + case ARDUINO_EVENT_ETH_GOT_IP: + #else case SYSTEM_EVENT_ETH_GOT_IP: + #endif Serial.print("ETH MAC: "); Serial.print(ETH.macAddress()); Serial.print(", IPv4: "); @@ -62,14 +80,25 @@ void ETHEvent(WiFiEvent_t event) Serial.println("Mbps"); eth_connected = true; break; + + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + case ARDUINO_EVENT_ETH_DISCONNECTED: + #else case SYSTEM_EVENT_ETH_DISCONNECTED: + #endif Serial.println("ETH Disconnected"); eth_connected = false; break; + + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + case ARDUINO_EVENT_ETH_STOP: + #else case SYSTEM_EVENT_ETH_STOP: + #endif Serial.println("ETH Stopped"); eth_connected = false; break; + default: break; } @@ -81,15 +110,19 @@ void setup() Serial.println("Starting ETH"); WiFi.onEvent(ETHEvent); + #if ESP_ARDUINO_VERSION_MAJOR >= 3 + ETH.begin(ETH_TYPE, ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_CLK_MODE); + #else ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); + #endif while (!eth_connected) { - Serial.println("connecting to ETH.."); + Serial.println("Connecting to ETH.."); delay(1000); } Serial.println("Connected"); - //Add CA Certificate + // Add CA Certificate secure_presentation_layer.setCACert(root_ca); } diff --git a/examples/Esp32-Arduino-IDE/https_gsm_SIM7000/https_gsm_SIM7000.ino b/examples/Esp32-Arduino-IDE/https_gsm_SIM7000/https_gsm_SIM7000.ino index e820005..c0c746f 100644 --- a/examples/Esp32-Arduino-IDE/https_gsm_SIM7000/https_gsm_SIM7000.ino +++ b/examples/Esp32-Arduino-IDE/https_gsm_SIM7000/https_gsm_SIM7000.ino @@ -12,9 +12,9 @@ * https://github.com/Xinyuan-LilyGO/LilyGO-T-SIM7000G/blob/master/examples/Arduino_Azure_IoTHub/Arduino_Azure_IoTHub.ino * **************************************************************/ -#include "SSLClient.h" //To make http request esay: https://github.com/arduino-libraries/ArduinoHttpClient #include +#include "SSLClient.h" //Please enter your CA certificate in ca_cert.h #include "ca_cert.h" diff --git a/examples/Esp32-Arduino-IDE/https_gsm_SIM800/https_gsm_SIM800.ino b/examples/Esp32-Arduino-IDE/https_gsm_SIM800/https_gsm_SIM800.ino index 2e3f829..9991bc8 100644 --- a/examples/Esp32-Arduino-IDE/https_gsm_SIM800/https_gsm_SIM800.ino +++ b/examples/Esp32-Arduino-IDE/https_gsm_SIM800/https_gsm_SIM800.ino @@ -10,10 +10,10 @@ * Base example: https://github.com/Xinyuan-LilyGO/LilyGo-T-Call-SIM800/tree/master/examples/Arduino_TinyGSM * **************************************************************/ -#include -#include "SSLClient.h" //To make http request esay: https://github.com/arduino-libraries/ArduinoHttpClient #include +#include +#include "SSLClient.h" //Please enter your CA certificate in ca_cert.h #include "ca_cert.h" diff --git a/examples/Esp32-Arduino-IDE/https_wifi/https_wifi.ino b/examples/Esp32-Arduino-IDE/https_wifi/https_wifi.ino index 4000431..6b56d49 100644 --- a/examples/Esp32-Arduino-IDE/https_wifi/https_wifi.ino +++ b/examples/Esp32-Arduino-IDE/https_wifi/https_wifi.ino @@ -6,10 +6,10 @@ * **************************************************************/ -#include "WiFi.h" -#include "SSLClient.h" //To make http request esay: https://github.com/arduino-libraries/ArduinoHttpClient #include +#include "WiFi.h" +#include "SSLClient.h" //Please enter your CA certificate in ca_cert.h #include "secrets.h" diff --git a/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/platformio.ini b/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/platformio.ini index ed68aed..f8937cf 100644 --- a/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/platformio.ini +++ b/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/platformio.ini @@ -18,7 +18,7 @@ lib_deps = vshymanskyy/TinyGSM@^0.11.7 vshymanskyy/StreamDebugger@^1.0.1 ; digitaldragon/SSLClient@^1.2.0 - https://github.com/govorox/SSLClient#v1.3.0 + https://github.com/govorox/SSLClient#95-release-130-fails-to-compile-on-arduino-esp32-v3 arduino-libraries/ArduinoHttpClient@^0.6.0 build_flags = -I include @@ -37,3 +37,21 @@ board = esp32doit-devkit-v1 [env:esp-wrover-kit] board = esp-wrover-kit + +[env:esp32dev-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32dev + +[env:esp32doit-devkit-v1-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32doit-devkit-v1 + +[env:esp-wrover-kit-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp-wrover-kit diff --git a/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/src/main.cpp b/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/src/main.cpp index 717a3c7..28c756d 100644 --- a/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/src/main.cpp +++ b/examples/Esp32-platformIO/t-call-esp32-sim800l-alpn-protos/src/main.cpp @@ -3,6 +3,7 @@ #include #include "ca_cert.h" #include +#include #define MODEM_UART_BAUD 115200 #define MODEM_RST 5 @@ -165,7 +166,7 @@ void loop() { serialMonitor.println("GPRS disconnected"); digitalWrite(LED_PIN, LOW); - //Turn off the moden (if use, you need run setupModem() again) + //Turn off the modem (if use, you need run setupModem() again) //modem.poweroff(); //serialMonitor.println("Modem poweroff"); //delay(1000); diff --git a/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/platformio.ini b/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/platformio.ini index 58e4201..0299de8 100644 --- a/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/platformio.ini +++ b/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/platformio.ini @@ -12,12 +12,12 @@ platform = espressif32 framework = arduino lib_deps = + arduino-libraries/ArduinoHttpClient@^0.6.0 vshymanskyy/TinyGSM@^0.11.7 knolleary/PubSubClient@^2.8 vshymanskyy/StreamDebugger@^1.0.1 ; digitaldragon/SSLClient@^1.2.0 - https://github.com/govorox/SSLClient#v1.3.0 - arduino-libraries/ArduinoHttpClient@^0.6.0 + https://github.com/govorox/SSLClient#95-release-130-fails-to-compile-on-arduino-esp32-v3 build_flags = -I include -D CORE_DEBUG_LEVEL=3 @@ -33,4 +33,23 @@ board = esp32dev board = esp32doit-devkit-v1 [env:esp-wrover-kit] -board = esp-wrover-kit \ No newline at end of file +board = esp-wrover-kit + +[env:esp32dev-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32dev + +[env:esp32doit-devkit-v1-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32doit-devkit-v1 + +[env:esp-wrover-kit-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp-wrover-kit + diff --git a/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/src/main.cpp b/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/src/main.cpp index 580b167..65de7a5 100644 --- a/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/src/main.cpp +++ b/examples/Esp32-platformIO/t-call-esp32-sim800l-aws/src/main.cpp @@ -1,8 +1,8 @@ #include -#include #include -#include #include +#include +#include #include #include #include "ca_cert.h" diff --git a/examples/Esp32-platformIO/t-call-esp32-sim800l-cert-bundle/platformio.ini b/examples/Esp32-platformIO/t-call-esp32-sim800l-cert-bundle/platformio.ini index 1d75d98..66660a4 100644 --- a/examples/Esp32-platformIO/t-call-esp32-sim800l-cert-bundle/platformio.ini +++ b/examples/Esp32-platformIO/t-call-esp32-sim800l-cert-bundle/platformio.ini @@ -23,7 +23,7 @@ board_build.embed_files = data/crt/x509_crt_bundle.bin lib_deps = vshymanskyy/TinyGSM@^0.11.7 ; digitaldragon/SSLClient@^1.2.0 - https://github.com/govorox/SSLClient#v1.3.0 + https://github.com/govorox/SSLClient#95-release-130-fails-to-compile-on-arduino-esp32-v3 [env:esp32dev] board = esp32dev @@ -34,6 +34,24 @@ board = esp32doit-devkit-v1 [env:esp-wrover-kit] board = esp-wrover-kit +[env:esp32dev-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32dev + +[env:esp32doit-devkit-v1-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp32doit-devkit-v1 + +[env:esp-wrover-kit-framework-v3] +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.2 + framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.2/esp32-arduino-libs-3.0.2.zip +board = esp-wrover-kit + ; Microcontroller config (ESP32-WROVER-E with 4MB Flash) board_build.f_flash = 80000000L board_upload.flash_size = 4MB diff --git a/library.json b/library.json index 26d7ca1..91701e1 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "SSLClient", - "version": "1.3.0", + "version": "1.3.1", "repository": { "type": "git", diff --git a/library.properties b/library.properties index e8690b7..beb747f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=GovoroxSSLClient -version=1.3.0 +version=1.3.1 author=V Govorovski maintainer=Robert Byrnes sentence=Provides secure network connection over a generic Client transport object. diff --git a/platformio.ini b/platformio.ini index 998ae08..b6d719f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -default_envs = native +default_envs = esp32dev [env:native] platform = native diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..fe2d76f --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,91 @@ +[![Back to README](https://img.shields.io/badge/Back_to-_README-blue?style=for-the-badge)](../README.md) + +# Scripts + +This directory contains scripts to help with the development of the SSLClient library. + +## Table of Contents +1. [Library Installation Script](#SSLClient-Library-Installation-Script) - Automates the installation of the SSLClient library. +2. [Arduino CLI Utility Script](#Arduino-CLI-Utility-Script) - Provides a convenient way to manage Arduino libraries, platforms, and frameworks. +3. [PlatformIO CLI Utility Script](#PlatformIO-CLI-Utility-Script) - Provides a convenient way to manage libraries, platforms, and frameworks using the PlatformIO CLI. + +## SSLClient Library Installation Script + +This script automates the process of cloning and installing the `SSLClient` library from a specified branch of the repository. It prepares the library for use with the Arduino CLI. + +### Usage + +Run from the root of the repository: + +`./scripts/install_sslclient_for_testing.sh` [--branch ] + +#### Parameters + +`--branch `: (Optional) Specify the branch to checkout. Defaults to master. + +### Script Overview + +1. Cloning the Repository: The script clones the SSLClient repository from GitHub. +2. Branch Checkout: It checks out the specified branch (or defaults to master). +3. Library Preparation: The script prepares the library by moving necessary files and creating a zip archive. +4. Installation: Finally, the script installs the library using the Arduino CLI. + +### Requirements + +`git` +`bash` +`arduino-cli` + +## Arduino CLI Utility Script + +This script provides a convenient way to manage Arduino libraries, platforms, and frameworks using the Arduino CLI. It also allows you to switch between different versions of the ESP32-Arduino core. + +### Usage + +`./scripts/arduino_cli_utility.sh` - Run the script to manage libraries, platforms, frameworks, and ESP32-Arduino versions. + +### Menu Options + +**List Installed Libraries:** Displays a list of all libraries currently installed. +**List Installed Platforms:** Displays a list of all platforms currently installed. +**List Installed Frameworks for Boards:** Displays a list of all available frameworks for boards. +**Switch ESP32-Arduino Version:** Prompts you to enter a specific version of the ESP32-Arduino core to install. +**Exit:** Exits the script. + +### Requirements + +`arduino-cli` - Ensure that arduino-cli is installed and properly configured on your system before running the script. + +### Script Overview +1. Library Management: List all installed libraries. +2. Platform Management: List all installed platforms. +3. Framework Management: List all available frameworks for boards. +4. ESP32 Version Management: Switch to a specific version of the ESP32-Arduino core. + +## PlatformIO CLI Utility Script + +This script provides a convenient way to manage libraries, platforms, and frameworks using the PlatformIO CLI. It also allows you to switch between different versions of the Arduino-ESP32 core. + +### Usage + +`./scripts/platformio_cli_utility.sh` - Run the script to manage libraries, platforms, frameworks, and Arduino-ESP32 versions. + +### Menu Options + +**List Installed Libraries:** Displays a list of all libraries currently installed. +**List Installed Platforms:** Displays a list of all platforms currently installed. +**List Installed Frameworks for Boards:** Displays a list of all available frameworks for boards that use the Arduino framework. +**Switch Arduino-ESP32 Version:** Prompts you to enter a specific version of the Arduino-ESP32 core to install. +**Exit:** Exits the script. + +### Requirements + +`bash` +`platformio-cli` (pio) + +### Script Overview + +1. Library Management: List all installed libraries using PlatformIO. +2. Platform Management: List all installed platforms using PlatformIO. +3. Framework Management: List all available frameworks for boards that support the Arduino framework using PlatformIO. +4. Arduino-ESP32 Version Management: Switch to a specific version of the Arduino-ESP32 core using PlatformIO. diff --git a/.github/workflows/scripts/compile_arduino_examples.sh b/scripts/compile_arduino_examples.sh similarity index 100% rename from .github/workflows/scripts/compile_arduino_examples.sh rename to scripts/compile_arduino_examples.sh diff --git a/.github/workflows/scripts/compile_pio_examples.sh b/scripts/compile_pio_examples.sh similarity index 92% rename from .github/workflows/scripts/compile_pio_examples.sh rename to scripts/compile_pio_examples.sh index 8b15cb8..540090d 100755 --- a/.github/workflows/scripts/compile_pio_examples.sh +++ b/scripts/compile_pio_examples.sh @@ -4,8 +4,15 @@ ROOT_DIR=$(pwd) CLEAN=false -# Boards to test -BOARDS=("esp32dev" "esp32doit-devkit-v1" "esp-wrover-kit") +# Environments to test +ENVIRONMENTS=( + "esp32dev" + "esp32doit-devkit-v1" + "esp-wrover-kit" + "esp32dev-framework-v3" + "esp32doit-devkit-v1-framework-v3" + "esp-wrover-kit-framework-v3" +) # Parse command line options while [[ "$#" -gt 0 ]]; do @@ -87,7 +94,7 @@ for example_dir in "$ROOT_DIR"/examples/Esp32-platformIO/*/; do echo "$example_dir" # Check if the directory contains platformio.ini if [ -f "$example_dir/platformio.ini" ]; then - for board in "${BOARDS[@]}"; do + for board in "${ENVIRONMENTS[@]}"; do compile_example "$example_dir" "$board" done diff --git a/scripts/install_sslclient_for_testing.sh b/scripts/install_sslclient_for_testing.sh new file mode 100755 index 0000000..df18c2c --- /dev/null +++ b/scripts/install_sslclient_for_testing.sh @@ -0,0 +1,56 @@ +#!/usr/bin/bash + +# Function to print usage +print_usage() { + echo "Usage: $0 [--branch ]" + echo " --branch Specify the branch to checkout (default: master)" +} + +# Default branch name +BRANCH="master" + +# Parse command line arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --branch) + if [[ -n $2 && ! $2 =~ ^- ]]; then + BRANCH=$2 + shift + else + echo "Error: --branch requires a non-empty option argument." + print_usage + exit 1 + fi + ;; + *) + echo "Unknown parameter passed: $1" + print_usage + exit 1 + ;; + esac + shift +done + +# Remove previous SSLClient directory if exists +rm -rf ~/SSLClient + +# Clone the repository +git clone https://github.com/govorox/SSLClient.git ~/SSLClient + +# Navigate to the cloned directory +cd ~/SSLClient || { echo "Failed to change directory to ~/SSLClient"; exit 1; } + +# Checkout the specified branch +git checkout "$BRANCH" + +# Prepare the directory for zipping +mkdir -p SSLClient +mv LICENSE library.properties src SSLClient/ +zip -r SSLClient.zip SSLClient + +# Create Arduino CLI configuration directory and file if not exists +mkdir -p ~/.arduino15 +echo -e "library:\n enable_unsafe_install: true" > ~/.arduino15/arduino-cli.yaml + +# Install the library using Arduino CLI +arduino-cli lib install --config-file ~/.arduino15/arduino-cli.yaml --zip-path SSLClient.zip diff --git a/.github/workflows/scripts/test_arduino_platform.sh b/scripts/test_arduino_platform.sh similarity index 100% rename from .github/workflows/scripts/test_arduino_platform.sh rename to scripts/test_arduino_platform.sh diff --git a/scripts/test_pio_platform.sh b/scripts/test_pio_platform.sh new file mode 100755 index 0000000..62263b1 --- /dev/null +++ b/scripts/test_pio_platform.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Function to list installed libraries +list_installed_libs() { + echo "Listing installed libraries..." + pio lib list +} + +# Function to list installed platforms +list_installed_platforms() { + echo "Listing installed platforms..." + pio platform list +} + +# Function to list installed frameworks for boards +list_installed_frameworks() { + echo "Listing installed frameworks for boards..." + pio boards --framework arduino +} + +# Function to switch to a specific arduino-esp32 version +switch_esp32_version() { + local version=$1 + echo "Switching to arduino-esp32 version $version..." + pio platform install espressif32@$version +} + +# Check if pio is installed +if ! command -v pio &> /dev/null; then + echo "PlatformIO CLI (pio) could not be found, please install it first." + exit 1 +fi + +# Main script +echo "PlatformIO CLI Utility Script" +echo "1. List installed libraries" +echo "2. List installed platforms" +echo "3. List installed frameworks for boards" +echo "4. Switch arduino-esp32 version" +echo "5. Exit" + +while true; do + read -p "Please select an option (1-5): " option + case $option in + 1) + list_installed_libs + ;; + 2) + list_installed_platforms + ;; + 3) + list_installed_frameworks + ;; + 4) + read -p "Enter the arduino-esp32 version to switch to (e.g., 2.0.16 or 3.0.0): " version + switch_esp32_version $version + ;; + 5) + echo "Exiting..." + exit 0 + ;; + *) + echo "Invalid option, please try again." + ;; + esac +done diff --git a/src/ssl__client.cpp b/src/ssl__client.cpp index bd8a674..4e16ec1 100644 --- a/src/ssl__client.cpp +++ b/src/ssl__client.cpp @@ -11,6 +11,9 @@ #endif #include "ssl__client.h" #include "certBundle.h" +#include + +using namespace std; #if !defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) # error "Please configure IDF framework to include mbedTLS -> Enable pre-shared-key ciphersuites and activate at least one cipher" diff --git a/src/ssl__client.h b/src/ssl__client.h index dc009db..f4dec40 100644 --- a/src/ssl__client.h +++ b/src/ssl__client.h @@ -34,8 +34,6 @@ #define SSL_CLIENT_UNRELIABLE_NETWORK_HANDSHAKE_TIMEOUT 45000U #define SSL_CLIENT_SEND_BUFFER_SIZE 1024U -using namespace std; - typedef struct sslclient__context { Client* client;