@@ -208,7 +208,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
208
208
_ota_img_sha256 = sha256_str;
209
209
#endif /* OTA_ENABLED */
210
210
211
- # ifdef BOARD_HAS_OFFLOADED_ECCX08
211
+ # if defined(BOARD_HAS_ECCX08) || defined( BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_SE050)
212
212
if (!_crypto.begin ())
213
213
{
214
214
DEBUG_ERROR (" _crypto.begin() failed." );
@@ -219,38 +219,29 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
219
219
DEBUG_ERROR (" _crypto.readDeviceId(...) failed." );
220
220
return 0 ;
221
221
}
222
- #endif
222
+ #endif
223
223
224
- #if defined(BOARD_HAS_ECCX08) || defined(BOARD_HAS_SE050)
225
- if (!_crypto.begin ())
226
- {
227
- DEBUG_ERROR (" Cryptography processor failure. Make sure you have a compatible board." );
228
- return 0 ;
229
- }
230
- if (!_crypto.readDeviceId (getDeviceId (), CryptoSlot::DeviceId))
231
- {
232
- DEBUG_ERROR (" Cryptography processor read failure." );
233
- return 0 ;
234
- }
224
+ #if defined(BOARD_HAS_ECCX08) || defined(BOARD_HAS_SE050)
235
225
if (!_crypto.readCert (_cert, CryptoSlot::CompressedCertificate))
236
226
{
237
227
DEBUG_ERROR (" Cryptography certificate reconstruction failure." );
238
228
return 0 ;
239
229
}
240
- #ifndef BOARD_HAS_SE050
230
+ _sslClient.setEccSlot (static_cast <int >(CryptoSlot::Key), _cert.bytes (), _cert.length ());
231
+ #endif
232
+
233
+ #if defined(BOARD_HAS_ECCX08)
241
234
_sslClient.setClient (_connection->getClient ());
242
- # else
235
+ # elif defined(BOARD_HAS_SE050)
243
236
_sslClient.appendCustomCACert (AIoTSSCert);
244
- #endif
245
- _sslClient.setEccSlot (static_cast <int >(CryptoSlot::Key), _cert.bytes (), _cert.length ());
246
- #elif defined(BOARD_ESP)
237
+ #elif defined(BOARD_ESP)
247
238
_sslClient.setInsecure ();
248
- #endif
239
+ #endif
249
240
250
241
_mqttClient.setClient (_sslClient);
251
- #ifdef BOARD_ESP
242
+ #ifdef BOARD_ESP
252
243
_mqttClient.setUsernamePassword (getDeviceId (), _password);
253
- #endif
244
+ #endif
254
245
_mqttClient.onMessage (ArduinoIoTCloudTCP::onMessage);
255
246
_mqttClient.setKeepAliveInterval (30 * 1000 );
256
247
_mqttClient.setConnectionTimeout (1500 );
0 commit comments