From a34ce91e7a7087190a43c218fda122a2381b04ca Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 4 May 2023 08:55:18 +0200 Subject: [PATCH 1/2] Initial: Basic support for Portenta C33 RTC support and OTA support missing --- src/AIoTC_Config.h | 2 +- src/ArduinoIoTCloudTCP.cpp | 3 +++ src/ArduinoIoTCloudTCP.h | 7 +++++++ src/utility/time/TimeService.cpp | 9 ++++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index f169ecbd3..4ae83767d 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -126,7 +126,7 @@ #define HAS_TCP #endif -#if defined(ARDUINO_NICLA_VISION) +#if defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_PORTENTA_C33) #define BOARD_HAS_SE050 #define HAS_TCP #endif diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 5d0dd8f57..2e8b1bea8 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -166,6 +166,9 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress, #if defined(BOARD_HAS_ECCX08) _sslClient.setClient(_connection->getClient()); +#elif defined(ARDUINO_PORTENTA_C33) + _sslClient.setClient(_connection->getClient()); + _sslClient.setCACert(AIoTSSCert); #elif defined(BOARD_HAS_SE050) _sslClient.appendCustomCACert(AIoTSSCert); #elif defined(BOARD_ESP) diff --git a/src/ArduinoIoTCloudTCP.h b/src/ArduinoIoTCloudTCP.h index e8218c9e1..54b0d34f4 100644 --- a/src/ArduinoIoTCloudTCP.h +++ b/src/ArduinoIoTCloudTCP.h @@ -31,6 +31,9 @@ #include "tls/utility/CryptoUtil.h" #elif defined(BOARD_ESP) #include +#elif defined(ARDUINO_PORTENTA_C33) + #include "tls/utility/CryptoUtil.h" + #include #elif defined(BOARD_HAS_SE050) #include "tls/utility/CryptoUtil.h" #include @@ -146,6 +149,10 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass #elif defined(BOARD_ESP) WiFiClientSecure _sslClient; String _password; + #elif defined(ARDUINO_PORTENTA_C33) + ArduinoIoTCloudCertClass _cert; + SSLClient _sslClient; + CryptoUtil _crypto; #elif defined(BOARD_HAS_SE050) ArduinoIoTCloudCertClass _cert; WiFiSSLSE050Client _sslClient; diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index a9536caa0..3cae3eca1 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -330,8 +330,9 @@ void TimeServiceClass::initRTC() stm32h7_initRTC(); #elif defined (ARDUINO_ARCH_ESP32) esp32_initRTC(); -#elif ARDUINO_ARCH_ESP8266 +#elif defined (ARDUINO_ARCH_ESP8266) esp8266_initRTC(); +#elif defined (ARDUINO_PORTENTA_C33) #else #error "RTC not available for this architecture" #endif @@ -347,8 +348,9 @@ void TimeServiceClass::setRTC(unsigned long time) stm32h7_setRTC(time); #elif defined (ARDUINO_ARCH_ESP32) esp32_setRTC(time); -#elif ARDUINO_ARCH_ESP8266 +#elif defined (ARDUINO_ARCH_ESP8266) esp8266_setRTC(time); +#elif defined (ARDUINO_PORTENTA_C33) #else #error "RTC not available for this architecture" #endif @@ -364,8 +366,9 @@ unsigned long TimeServiceClass::getRTC() return stm32h7_getRTC(); #elif defined (ARDUINO_ARCH_ESP32) return esp32_getRTC(); -#elif ARDUINO_ARCH_ESP8266 +#elif defined (ARDUINO_ARCH_ESP8266) return esp8266_getRTC(); +#elif defined (ARDUINO_PORTENTA_C33) #else #error "RTC not available for this architecture" #endif From d85a55c1181cf20576ee3eaf24dcfc81280f28f5 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 12 Jun 2023 10:02:21 +0200 Subject: [PATCH 2/2] Portenta C33: Add RTC support --- src/utility/time/TimeService.cpp | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 3cae3eca1..eeab3245d 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -38,6 +38,10 @@ #include "RTCMillis.h" #endif +#ifdef ARDUINO_ARCH_RENESAS + #include "RTC.h" +#endif + /************************************************************************************** * GLOBAL VARIABLES **************************************************************************************/ @@ -86,6 +90,12 @@ void esp8266_setRTC(unsigned long time); unsigned long esp8266_getRTC(); #endif +#ifdef ARDUINO_ARCH_RENESAS +void renesas_initRTC(); +void renesas_setRTC(unsigned long time); +unsigned long renesas_getRTC(); +#endif + /************************************************************************************** * CONSTANTS **************************************************************************************/ @@ -332,7 +342,8 @@ void TimeServiceClass::initRTC() esp32_initRTC(); #elif defined (ARDUINO_ARCH_ESP8266) esp8266_initRTC(); -#elif defined (ARDUINO_PORTENTA_C33) +#elif defined (ARDUINO_ARCH_RENESAS) + renesas_initRTC(); #else #error "RTC not available for this architecture" #endif @@ -350,7 +361,8 @@ void TimeServiceClass::setRTC(unsigned long time) esp32_setRTC(time); #elif defined (ARDUINO_ARCH_ESP8266) esp8266_setRTC(time); -#elif defined (ARDUINO_PORTENTA_C33) +#elif defined (ARDUINO_ARCH_RENESAS) + renesas_setRTC(time); #else #error "RTC not available for this architecture" #endif @@ -368,7 +380,8 @@ unsigned long TimeServiceClass::getRTC() return esp32_getRTC(); #elif defined (ARDUINO_ARCH_ESP8266) return esp8266_getRTC(); -#elif defined (ARDUINO_PORTENTA_C33) +#elif defined (ARDUINO_ARCH_RENESAS) + return renesas_getRTC(); #else #error "RTC not available for this architecture" #endif @@ -494,6 +507,26 @@ unsigned long esp8266_getRTC() } #endif +#ifdef ARDUINO_ARCH_RENESAS +void renesas_initRTC() +{ + RTC.begin(); +} + +void renesas_setRTC(unsigned long time) +{ + RTCTime t(time); + RTC.setTime(t); +} + +unsigned long renesas_getRTC() +{ + RTCTime t; + RTC.getTime(t); + return t.getUnixTime(); +} +#endif + /****************************************************************************** * EXTERN DEFINITION ******************************************************************************/