Skip to content
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

Add UNO R4 WiFi basic support #366

Merged
merged 7 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 9 additions & 1 deletion .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
type: mbed_giga
- fqbn: arduino:renesas_portenta:portenta_c33
type: renesas_portenta
- fqbn: arduino:renesas_uno:unor4wifi
type: renesas_uno


# make board type-specific customizations to the matrix jobs
Expand Down Expand Up @@ -177,14 +179,20 @@ jobs:
- name: Arduino_Portenta_OTA
sketch-paths: |
- examples/utility/Provisioning
# Portneta C33
# Portenta C33
- board:
type: renesas_portenta
platforms: |
# Install renesas_portenta platform via Boards Manager
- name: arduino:renesas_portenta
sketch-paths: |
- examples/utility/Provisioning
# UNO R4 WiFi
- board:
type: renesas_uno
platforms: |
# Install renesas_uno platform via Boards Manager
- name: arduino:renesas_uno
# ESP8266 boards
- board:
type: esp8266
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ sentence=This library allows connecting to the Arduino IoT Cloud service.
paragraph=It provides a ConnectionManager to handle connection/disconnection, property-change updates and events callbacks. The supported boards are MKR GSM, MKR1000 and WiFi101.
category=Communication
url=https://github.com/arduino-libraries/ArduinoIoTCloud
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta,renesas_uno
includes=ArduinoIoTCloud.h
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,ArduinoMqttClient,ArduinoECCX08,RTCZero,Adafruit SleepyDog Library,Arduino_ESP32_OTA,Arduino_Portenta_OTA
5 changes: 5 additions & 0 deletions src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
#define BOARD_STM32H7
#endif

#if defined(ARDUINO_UNOR4_WIFI)
#define BOARD_HAS_SECRET_KEY
#define HAS_TCP
#endif

/******************************************************************************
* CONSTANTS
******************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
reconnection_retry_delay = min(reconnection_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
_next_connection_attempt_tick = millis() + reconnection_retry_delay;

#if defined(ARDUINO_UNOWIFIR4)
if (String(WiFi.firmwareVersion()) < String("0.2.0")) {
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, WiFI firmware needs to be >= 0.2.0, current %s", __FUNCTION__, WiFi.firmwareVersion());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should read WiFi firmware instead of WiFI firmware (with lowercase i)

}
#endif

DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not connect to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
DEBUG_ERROR("ArduinoIoTCloudTCP::%s %d connection attempt at tick time %d", __FUNCTION__, _last_connection_attempt_cnt, _next_connection_attempt_tick);
return State::ConnectPhy;
Expand Down
4 changes: 4 additions & 0 deletions src/ArduinoIoTCloudTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "tls/utility/CryptoUtil.h"
#elif defined(BOARD_ESP)
#include <WiFiClientSecure.h>
#elif defined(ARDUINO_UNOR4_WIFI)
#include <WiFiSSLClient.h>
#elif defined(ARDUINO_PORTENTA_C33)
#include "tls/utility/CryptoUtil.h"
#include <SSLClient.h>
Expand Down Expand Up @@ -148,6 +150,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
CryptoUtil _crypto;
#elif defined(BOARD_ESP)
WiFiClientSecure _sslClient;
#elif defined(ARDUINO_UNOR4_WIFI)
WiFiSSLClient _sslClient;
#elif defined(ARDUINO_PORTENTA_C33)
ArduinoIoTCloudCertClass _cert;
SSLClient _sslClient;
Expand Down
63 changes: 37 additions & 26 deletions src/utility/time/TimeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ void renesas_setRTC(unsigned long time);
unsigned long renesas_getRTC();
#endif

/**************************************************************************************
* DEFINES
**************************************************************************************/

#define EPOCH_AT_COMPILE_TIME cvt_time(__DATE__)

/**************************************************************************************
* CONSTANTS
**************************************************************************************/

/* Default NTP synch is scheduled each 24 hours from startup */
static time_t const TIMESERVICE_NTP_SYNC_TIMEOUT_ms = DAYS * 1000;
static time_t const EPOCH_AT_COMPILE_TIME = cvt_time(__DATE__);
static time_t const EPOCH = 0;

/**************************************************************************************
Expand Down Expand Up @@ -393,32 +398,38 @@ unsigned long TimeServiceClass::getRTC()

time_t cvt_time(char const * time)
{
char s_month[5];
int month, day, year;
struct tm t =
{
0 /* tm_sec */,
0 /* tm_min */,
0 /* tm_hour */,
0 /* tm_mday */,
0 /* tm_mon */,
0 /* tm_year */,
0 /* tm_wday */,
0 /* tm_yday */,
0 /* tm_isdst */
};
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";

sscanf(time, "%s %d %d", s_month, &day, &year);

month = (strstr(month_names, s_month) - month_names) / 3;

t.tm_mon = month;
t.tm_mday = day;
t.tm_year = year - 1900;
t.tm_isdst = -1;
static time_t build_time = 0;

if (!build_time) {
char s_month[5];
int month, day, year;
struct tm t =
{
0 /* tm_sec */,
0 /* tm_min */,
0 /* tm_hour */,
0 /* tm_mday */,
0 /* tm_mon */,
0 /* tm_year */,
0 /* tm_wday */,
0 /* tm_yday */,
0 /* tm_isdst */
};
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";

sscanf(time, "%s %d %d", s_month, &day, &year);

month = (strstr(month_names, s_month) - month_names) / 3;

t.tm_mon = month;
t.tm_mday = day;
t.tm_year = year - 1900;
t.tm_isdst = -1;

build_time = mktime(&t);
}

return mktime(&t);
return build_time;
}

#ifdef ARDUINO_ARCH_SAMD
Expand Down
Loading