Skip to content

Commit 9163dcb

Browse files
authored
Merge pull request #366 from pennam/unor4
Add UNO R4 WiFi basic support
2 parents a50ab82 + 2cbe1e8 commit 9163dcb

File tree

6 files changed

+62
-28
lines changed

6 files changed

+62
-28
lines changed

Diff for: .github/workflows/compile-examples.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
type: mbed_giga
6565
- fqbn: arduino:renesas_portenta:portenta_c33
6666
type: renesas_portenta
67+
- fqbn: arduino:renesas_uno:unor4wifi
68+
type: renesas_uno
6769

6870

6971
# make board type-specific customizations to the matrix jobs
@@ -177,14 +179,20 @@ jobs:
177179
- name: Arduino_Portenta_OTA
178180
sketch-paths: |
179181
- examples/utility/Provisioning
180-
# Portneta C33
182+
# Portenta C33
181183
- board:
182184
type: renesas_portenta
183185
platforms: |
184186
# Install renesas_portenta platform via Boards Manager
185187
- name: arduino:renesas_portenta
186188
sketch-paths: |
187189
- examples/utility/Provisioning
190+
# UNO R4 WiFi
191+
- board:
192+
type: renesas_uno
193+
platforms: |
194+
# Install renesas_uno platform via Boards Manager
195+
- name: arduino:renesas_uno
188196
# ESP8266 boards
189197
- board:
190198
type: esp8266

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ sentence=This library allows connecting to the Arduino IoT Cloud service.
66
paragraph=It provides a ConnectionManager to handle connection/disconnection, property-change updates and events callbacks. The supported boards are MKR GSM, MKR1000 and WiFi101.
77
category=Communication
88
url=https://github.com/arduino-libraries/ArduinoIoTCloud
9-
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta
9+
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta,renesas_uno
1010
includes=ArduinoIoTCloud.h
1111
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,ArduinoMqttClient,ArduinoECCX08,RTCZero,Adafruit SleepyDog Library,Arduino_ESP32_OTA,Arduino_Portenta_OTA

Diff for: src/AIoTC_Config.h

+5
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@
151151
#define BOARD_STM32H7
152152
#endif
153153

154+
#if defined(ARDUINO_UNOR4_WIFI)
155+
#define BOARD_HAS_SECRET_KEY
156+
#define HAS_TCP
157+
#endif
158+
154159
/******************************************************************************
155160
* CONSTANTS
156161
******************************************************************************/

Diff for: src/ArduinoIoTCloudTCP.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
327327
reconnection_retry_delay = min(reconnection_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
328328
_next_connection_attempt_tick = millis() + reconnection_retry_delay;
329329

330+
#if defined(ARDUINO_UNOWIFIR4)
331+
if (String(WiFi.firmwareVersion()) < String("0.2.0")) {
332+
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());
333+
}
334+
#endif
335+
330336
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not connect to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);
331337
DEBUG_ERROR("ArduinoIoTCloudTCP::%s %d connection attempt at tick time %d", __FUNCTION__, _last_connection_attempt_cnt, _next_connection_attempt_tick);
332338
return State::ConnectPhy;

Diff for: src/ArduinoIoTCloudTCP.h

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "tls/utility/CryptoUtil.h"
3232
#elif defined(BOARD_ESP)
3333
#include <WiFiClientSecure.h>
34+
#elif defined(ARDUINO_UNOR4_WIFI)
35+
#include <WiFiSSLClient.h>
3436
#elif defined(ARDUINO_PORTENTA_C33)
3537
#include "tls/utility/CryptoUtil.h"
3638
#include <SSLClient.h>
@@ -148,6 +150,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
148150
CryptoUtil _crypto;
149151
#elif defined(BOARD_ESP)
150152
WiFiClientSecure _sslClient;
153+
#elif defined(ARDUINO_UNOR4_WIFI)
154+
WiFiSSLClient _sslClient;
151155
#elif defined(ARDUINO_PORTENTA_C33)
152156
ArduinoIoTCloudCertClass _cert;
153157
SSLClient _sslClient;

Diff for: src/utility/time/TimeService.cpp

+37-26
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,18 @@ void renesas_setRTC(unsigned long time);
9696
unsigned long renesas_getRTC();
9797
#endif
9898

99+
/**************************************************************************************
100+
* DEFINES
101+
**************************************************************************************/
102+
103+
#define EPOCH_AT_COMPILE_TIME cvt_time(__DATE__)
104+
99105
/**************************************************************************************
100106
* CONSTANTS
101107
**************************************************************************************/
102108

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

108113
/**************************************************************************************
@@ -393,32 +398,38 @@ unsigned long TimeServiceClass::getRTC()
393398

394399
time_t cvt_time(char const * time)
395400
{
396-
char s_month[5];
397-
int month, day, year;
398-
struct tm t =
399-
{
400-
0 /* tm_sec */,
401-
0 /* tm_min */,
402-
0 /* tm_hour */,
403-
0 /* tm_mday */,
404-
0 /* tm_mon */,
405-
0 /* tm_year */,
406-
0 /* tm_wday */,
407-
0 /* tm_yday */,
408-
0 /* tm_isdst */
409-
};
410-
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
411-
412-
sscanf(time, "%s %d %d", s_month, &day, &year);
413-
414-
month = (strstr(month_names, s_month) - month_names) / 3;
415-
416-
t.tm_mon = month;
417-
t.tm_mday = day;
418-
t.tm_year = year - 1900;
419-
t.tm_isdst = -1;
401+
static time_t build_time = 0;
402+
403+
if (!build_time) {
404+
char s_month[5];
405+
int month, day, year;
406+
struct tm t =
407+
{
408+
0 /* tm_sec */,
409+
0 /* tm_min */,
410+
0 /* tm_hour */,
411+
0 /* tm_mday */,
412+
0 /* tm_mon */,
413+
0 /* tm_year */,
414+
0 /* tm_wday */,
415+
0 /* tm_yday */,
416+
0 /* tm_isdst */
417+
};
418+
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
419+
420+
sscanf(time, "%s %d %d", s_month, &day, &year);
421+
422+
month = (strstr(month_names, s_month) - month_names) / 3;
423+
424+
t.tm_mon = month;
425+
t.tm_mday = day;
426+
t.tm_year = year - 1900;
427+
t.tm_isdst = -1;
428+
429+
build_time = mktime(&t);
430+
}
420431

421-
return mktime(&t);
432+
return build_time;
422433
}
423434

424435
#ifdef ARDUINO_ARCH_SAMD

0 commit comments

Comments
 (0)