@@ -208,7 +208,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
208208 _ota_img_sha256 = sha256_str;
209209#endif /* OTA_ENABLED */
210210
211- # ifdef BOARD_HAS_OFFLOADED_ECCX08
211+ # if defined(BOARD_HAS_ECCX08) || defined( BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_SE050)
212212 if (!_crypto.begin ())
213213 {
214214 DEBUG_ERROR (" _crypto.begin() failed." );
@@ -219,38 +219,29 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
219219 DEBUG_ERROR (" _crypto.readDeviceId(...) failed." );
220220 return 0 ;
221221 }
222- #endif
222+ #endif
223223
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)
235225 if (!_crypto.readCert (_cert, CryptoSlot::CompressedCertificate))
236226 {
237227 DEBUG_ERROR (" Cryptography certificate reconstruction failure." );
238228 return 0 ;
239229 }
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)
241234 _sslClient.setClient (_connection->getClient ());
242- # else
235+ # elif defined(BOARD_HAS_SE050)
243236 _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)
247238 _sslClient.setInsecure ();
248- #endif
239+ #endif
249240
250241 _mqttClient.setClient (_sslClient);
251- #ifdef BOARD_ESP
242+ #ifdef BOARD_ESP
252243 _mqttClient.setUsernamePassword (getDeviceId (), _password);
253- #endif
244+ #endif
254245 _mqttClient.onMessage (ArduinoIoTCloudTCP::onMessage);
255246 _mqttClient.setKeepAliveInterval (30 * 1000 );
256247 _mqttClient.setConnectionTimeout (1500 );
0 commit comments