From f1d362af817bfa00484e21d7fcbbd5e0723fda01 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 29 Apr 2024 11:47:21 +0200 Subject: [PATCH] Do not include ArduinoBearSSL if ArduinoIoTCloud is included --- src/ArduinoCellular.cpp | 5 ++++- src/ArduinoCellular.h | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ArduinoCellular.cpp b/src/ArduinoCellular.cpp index 4477d75..7fb8b8e 100644 --- a/src/ArduinoCellular.cpp +++ b/src/ArduinoCellular.cpp @@ -35,8 +35,9 @@ void ArduinoCellular::begin() { modem.sendAT("+CNMI=2,1,0,0,0"); modem.waitResponse(); - +#if defined(ARDUINO_CELLULAR_BEARSSL) ArduinoBearSSL.onGetTime(ArduinoCellular::getTime); +#endif } @@ -155,6 +156,7 @@ HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){ return HttpClient(* new TinyGsmClient(modem), server, port); } +#if defined(ARDUINO_CELLULAR_BEARSSL) HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){ return HttpClient(* new BearSSLClient(* new TinyGsmClient(modem)), server, port); } @@ -162,6 +164,7 @@ HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){ BearSSLClient ArduinoCellular::getSecureNetworkClient(){ return BearSSLClient(* new TinyGsmClient(modem)); } +#endif bool ArduinoCellular::isConnectedToOperator(){ return modem.isNetworkConnected(); diff --git a/src/ArduinoCellular.h b/src/ArduinoCellular.h index c671b83..02fab3d 100644 --- a/src/ArduinoCellular.h +++ b/src/ArduinoCellular.h @@ -16,8 +16,18 @@ #include #include -#include "ArduinoBearSSLConfig.h" -#include + +#if defined __has_include + #if !__has_include () + #define ARDUINO_CELLULAR_BEARSSL + #endif +#endif + +#if defined(ARDUINO_CELLULAR_BEARSSL) + #include "ArduinoBearSSLConfig.h" + #include +#endif + #include #include @@ -206,7 +216,9 @@ class ArduinoCellular { * @brief Gets the Transport Layer Security (TLS) client. (OSI Layer 4) * @return The GSM client. */ +#if defined(ARDUINO_CELLULAR_BEARSSL) BearSSLClient getSecureNetworkClient(); +#endif /** * @brief Gets the HTTP client for the specified server and port.