Skip to content

Commit 4006615

Browse files
Merge pull request #13 from pennam/bearssl-fix
Do not include ArduinoBearSSL if ArduinoIoTCloud is included
2 parents 4e445aa + f1d362a commit 4006615

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Diff for: src/ArduinoCellular.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ void ArduinoCellular::begin() {
3535
modem.sendAT("+CNMI=2,1,0,0,0");
3636
modem.waitResponse();
3737

38-
38+
#if defined(ARDUINO_CELLULAR_BEARSSL)
3939
ArduinoBearSSL.onGetTime(ArduinoCellular::getTime);
40+
#endif
4041

4142
}
4243

@@ -155,13 +156,15 @@ HttpClient ArduinoCellular::getHTTPClient(const char * server, const int port){
155156
return HttpClient(* new TinyGsmClient(modem), server, port);
156157
}
157158

159+
#if defined(ARDUINO_CELLULAR_BEARSSL)
158160
HttpClient ArduinoCellular::getHTTPSClient(const char * server, const int port){
159161
return HttpClient(* new BearSSLClient(* new TinyGsmClient(modem)), server, port);
160162
}
161163

162164
BearSSLClient ArduinoCellular::getSecureNetworkClient(){
163165
return BearSSLClient(* new TinyGsmClient(modem));
164166
}
167+
#endif
165168

166169
bool ArduinoCellular::isConnectedToOperator(){
167170
return modem.isNetworkConnected();

Diff for: src/ArduinoCellular.h

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@
1616

1717
#include <Arduino.h>
1818
#include <vector>
19-
#include "ArduinoBearSSLConfig.h"
20-
#include <ArduinoBearSSL.h>
19+
20+
#if defined __has_include
21+
#if !__has_include (<ArduinoIoTCloud.h>)
22+
#define ARDUINO_CELLULAR_BEARSSL
23+
#endif
24+
#endif
25+
26+
#if defined(ARDUINO_CELLULAR_BEARSSL)
27+
#include "ArduinoBearSSLConfig.h"
28+
#include <ArduinoBearSSL.h>
29+
#endif
30+
2131
#include <ModemInterface.h>
2232
#include <TimeUtils.h>
2333

@@ -206,7 +216,9 @@ class ArduinoCellular {
206216
* @brief Gets the Transport Layer Security (TLS) client. (OSI Layer 4)
207217
* @return The GSM client.
208218
*/
219+
#if defined(ARDUINO_CELLULAR_BEARSSL)
209220
BearSSLClient getSecureNetworkClient();
221+
#endif
210222

211223
/**
212224
* @brief Gets the HTTP client for the specified server and port.

0 commit comments

Comments
 (0)