Skip to content

Commit 7a22914

Browse files
committed
Directly use WiFiSSLClient since we want to offload SSL on nina for MKR WIFI 1010
1 parent 0b45114 commit 7a22914

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/AIoTC_Config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
#define OTA_ENABLED (0)
7373
#endif
7474

75+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
76+
#define BOARD_HAS_NINA (1)
77+
#else
78+
#define BOARD_HAS_NINA (0)
79+
#endif
80+
7581
#if defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWIFI1010) || \
7682
defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
7783
defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_PORTENTA_H7_M7) || \

src/ArduinoIoTCloudTCP.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
5858
, _mqtt_data_buf{0}
5959
, _mqtt_data_len{0}
6060
, _mqtt_data_request_retransmit{false}
61-
#ifdef BOARD_HAS_ECCX08
61+
#if BOARD_HAS_NINA
62+
/* Do nothing here because we are using onboard onboard SSL on NINA. */
63+
#elif defined(BOARD_HAS_ECCX08)
6264
, _sslClient(nullptr, ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM, getTime)
6365
#endif
6466
#ifdef BOARD_ESP
@@ -112,15 +114,17 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
112114
_ota_img_sha256 = FlashSHA256::calc(0x2000, 0x40000 - 0x2000);
113115
#endif /* OTA_ENABLED */
114116

115-
#ifdef BOARD_HAS_ECCX08
117+
#if BOARD_HAS_NINA
118+
/* Do nothing here because we are using onboard SSL on NINA. */
119+
#elif defined(BOARD_HAS_ECCX08)
116120
if (!ECCX08.begin()) { DBG_ERROR(F("Cryptography processor failure. Make sure you have a compatible board.")); return 0; }
117121
if (!CryptoUtil::readDeviceId(ECCX08, getDeviceId(), ECCX08Slot::DeviceId)) { DBG_ERROR(F("Cryptography processor read failure.")); return 0; }
118122
if (!CryptoUtil::reconstructCertificate(_eccx08_cert, getDeviceId(), ECCX08Slot::Key, ECCX08Slot::CompressedCertificate, ECCX08Slot::SerialNumberAndAuthorityKeyIdentifier)) { DBG_ERROR(F("Cryptography certificate reconstruction failure.")); return 0; }
119123
_sslClient.setClient(_connection->getClient());
120124
_sslClient.setEccSlot(static_cast<int>(ECCX08Slot::Key), _eccx08_cert.bytes(), _eccx08_cert.length());
121-
#elif defined(BOARD_ESP)
125+
#elif defined(BOARD_ESP)
122126
_sslClient.setInsecure();
123-
#endif
127+
#endif
124128

125129
_mqttClient.setClient(_sslClient);
126130
#ifdef BOARD_ESP

src/ArduinoIoTCloudTCP.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
9898
int _mqtt_data_len;
9999
bool _mqtt_data_request_retransmit;
100100

101-
#ifdef BOARD_HAS_ECCX08
101+
#if BOARD_HAS_NINA
102+
WiFiSSLClient _sslClient;
103+
#elif defined(BOARD_HAS_ECCX08)
102104
ECCX08CertClass _eccx08_cert;
103105
BearSSLClient _sslClient;
104-
#elif defined(BOARD_ESP)
106+
#elif defined(BOARD_ESP)
105107
WiFiClientSecure _sslClient;
106108
String _password;
107-
#endif
109+
#endif
108110

109111
MqttClient _mqttClient;
110112

0 commit comments

Comments
 (0)