Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Portenta C33 Initial: use Arduino_SecureElement library #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions examples/AWS IoT/AWS_IoT_WiFi/AWS_IoT_WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@
This example code is in the public domain.
*/

#include <ArduinoBearSSL.h>
#include <ArduinoECCX08.h>
#include <Arduino_SecureElement.h>
#include <ArduinoMqttClient.h>
#include <WiFiNINA.h> // change to #include <WiFi101.h> for MKR1000
#if defined(ARDUINO_SAMD_MKR1000)
#include <WiFi101.h>
#elif defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
#include <WiFiNINA.h>
#elif defined(ARDUINO_PORTENTA_C33)
#include <WiFiC3.h>
#include <WiFiSSLClient.h>
#else
#error "Board not supported"
#endif

#if defined(BOARD_HAS_ECCX08)
#include <ArduinoBearSSL.h>
#endif

#include "arduino_secrets.h"

Expand All @@ -33,8 +45,13 @@ const char pass[] = SECRET_PASS;
const char broker[] = SECRET_BROKER;
const char* certificate = SECRET_CERTIFICATE;


#if defined(BOARD_HAS_ECCX08)
WiFiClient wifiClient; // Used for the TCP socket connection
BearSSLClient sslClient(wifiClient); // Used for SSL/TLS connection, integrates with ECC508
#else
WiFiSSLClient sslClient;
#endif
MqttClient mqttClient(sslClient);

unsigned long lastMillis = 0;
Expand All @@ -43,14 +60,18 @@ void setup() {
Serial.begin(115200);
while (!Serial);

if (!ECCX08.begin()) {
Serial.println("No ECCX08 present!");
SecureElement secureElement;

if (!secureElement.begin()) {
Serial.println("No Secure Element present!");
while (1);
}

#if defined(BOARD_HAS_ECCX08)
// Set a callback to get the current time
// used to validate the servers certificate
ArduinoBearSSL.onGetTime(getTime);
#endif

// Set the ECCX08 slot to use for the private key
// and the accompanying public certificate for it
Expand Down