From cbe3db0bdd813cc9ff5c0b5a4f75b3a61866324e Mon Sep 17 00:00:00 2001 From: Andrea Gilardoni Date: Thu, 14 Mar 2024 15:17:22 +0100 Subject: [PATCH 1/2] added getNewClient for tcp connections --- src/Arduino_GenericClient.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Arduino_GenericClient.h diff --git a/src/Arduino_GenericClient.h b/src/Arduino_GenericClient.h new file mode 100644 index 00000000..d5fa77e2 --- /dev/null +++ b/src/Arduino_GenericClient.h @@ -0,0 +1,32 @@ +#pragma once + +#include "Arduino_ConnectionHandler.h" + +namespace connectionHandler { + inline Client* getNewClient(NetworkAdapter net) { + switch(net) { +#ifdef BOARD_HAS_WIFI + case NetworkAdapter::WIFI: + return new WiFiClient(); +#endif // BOARD_HAS_WIFI +#ifdef BOARD_HAS_ETHERNET + case NetworkAdapter::ETHERNET: + return new EthernetClient(); +#endif // BOARD_HAS_ETHERNET +#ifdef BOARD_HAS_NB + case NetworkAdapter::NB: + return new NBClient(); +#endif // BOARD_HAS_NB +#ifdef BOARD_HAS_GSM + case NetworkAdapter::GSM: + return new GSMClient(); +#endif // BOARD_HAS_GSM +#ifdef BOARD_HAS_CATM1_NBIOT + case NetworkAdapter::CATM1: + return new GSMClient(); +#endif // BOARD_HAS_CATM1_NBIOT + default: + return nullptr; + } + } +} From 414e00c58f2ead2e99bac734e676a0ebac2f750c Mon Sep 17 00:00:00 2001 From: Andrea Gilardoni Date: Thu, 14 Mar 2024 15:17:46 +0100 Subject: [PATCH 2/2] added getNewSSLClient for ssl over tcp connections --- src/Arduino_GenericSSLClient.h | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Arduino_GenericSSLClient.h diff --git a/src/Arduino_GenericSSLClient.h b/src/Arduino_GenericSSLClient.h new file mode 100644 index 00000000..1a7ea1e8 --- /dev/null +++ b/src/Arduino_GenericSSLClient.h @@ -0,0 +1,48 @@ +#pragma once + +#include "Arduino_ConnectionHandler.h" + +#if defined(ARDUINO_UNOR4_WIFI) + #include +#elif defined(BOARD_STM32H7) + #include + #include "EthernetSSLClient.h" +#elif defined(ARDUINO_PORTENTA_C33) + #include "EthernetSSLClient.h" + #include +#elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) + #include + + namespace connectionHandler { + using WiFiSSLClient=WiFiClientSecure; + } +#endif + +namespace connectionHandler { + inline Client* getNewSSLClient(NetworkAdapter net) { + switch(net) { +#ifdef BOARD_HAS_WIFI + case NetworkAdapter::WIFI: + return new WiFiSSLClient(); +#endif // BOARD_HAS_WIFI +#ifdef BOARD_HAS_ETHERNET + case NetworkAdapter::ETHERNET: + return new EthernetSSLClient(); +#endif // BOARD_HAS_ETHERNET +#ifdef BOARD_HAS_NB + case NetworkAdapter::NB: + return new NBSSLClient(); +#endif // BOARD_HAS_NB +#ifdef BOARD_HAS_GSM + case NetworkAdapter::GSM: + return new GSMSSLClient(); +#endif // BOARD_HAS_GSM +#ifdef BOARD_HAS_CATM1_NBIOT + case NetworkAdapter::CATM1: + return new GSMSSLClient(); +#endif // BOARD_HAS_CATM1_NBIOT + default: + return nullptr; + } + } +}