Skip to content

Commit

Permalink
Merge pull request #13 from pennam/bearssl-fix
Browse files Browse the repository at this point in the history
Do not include ArduinoBearSSL if ArduinoIoTCloud is included
  • Loading branch information
cristidragomir97 authored May 7, 2024
2 parents 4e445aa + f1d362a commit 4006615
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/ArduinoCellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

Expand Down Expand Up @@ -155,13 +156,15 @@ 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);
}

BearSSLClient ArduinoCellular::getSecureNetworkClient(){
return BearSSLClient(* new TinyGsmClient(modem));
}
#endif

bool ArduinoCellular::isConnectedToOperator(){
return modem.isNetworkConnected();
Expand Down
16 changes: 14 additions & 2 deletions src/ArduinoCellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@

#include <Arduino.h>
#include <vector>
#include "ArduinoBearSSLConfig.h"
#include <ArduinoBearSSL.h>

#if defined __has_include
#if !__has_include (<ArduinoIoTCloud.h>)
#define ARDUINO_CELLULAR_BEARSSL
#endif
#endif

#if defined(ARDUINO_CELLULAR_BEARSSL)
#include "ArduinoBearSSLConfig.h"
#include <ArduinoBearSSL.h>
#endif

#include <ModemInterface.h>
#include <TimeUtils.h>

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4006615

Please sign in to comment.