Skip to content

Commit d8a3a98

Browse files
authored
Merge pull request #208 from arduino-libraries/offload-ssl-nina-take2
Offload IoT Cloud connection to Nina module
2 parents 457d932 + 8383de1 commit d8a3a98

28 files changed

+481
-61
lines changed

.github/workflows/compile-examples.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
{"fqbn": "arduino:samd:mkr1000", "type": "mkr1000"},
4242
{"fqbn": "arduino:samd:mkrwifi1010", "type": "nina"},
4343
{"fqbn": "arduino:samd:nano_33_iot", "type": "nina"},
44+
{"fqbn": "arduino:megaavr:uno2018", "type": "megaavr"},
4445
{"fqbn": "arduino:samd:mkrwan1300", "type": "wan"},
4546
{"fqbn": "arduino:samd:mkrgsm1400", "type": "gsm"},
4647
{"fqbn": "arduino:samd:mkrnb1500", "type": "nb"},
@@ -79,6 +80,20 @@ jobs:
7980
sketch-paths: |
8081
- examples/utility/Provisioning
8182
- examples/utility/SelfProvisioning
83+
# Uno WiFi Rev2
84+
- board:
85+
type: "megaavr"
86+
platforms: |
87+
- name: arduino:megaavr
88+
libraries: |
89+
- name: ArduinoECCX08
90+
- source-url: https://github.com/arduino-libraries/Arduino_AVRSTL.git
91+
- name: WiFiNINA
92+
- name: Arduino_JSON
93+
- name: ArduinoBearSSL
94+
sketch-paths: |
95+
- examples/utility/Provisioning
96+
- examples/utility/SelfProvisioning
8297
# LoRaWAN boards
8398
- board:
8499
type: "wan"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ sentence=This library allows to connect 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 MKRGSM, MKR1000 and WiFi101.
77
category=Communication
88
url=https://github.com/arduino-libraries/ArduinoIoTCloud
9-
architectures=mbed,samd,esp8266
9+
architectures=mbed,samd,esp8266,megaavr
1010
includes=ArduinoIoTCloud.h
1111
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,ArduinoMqttClient,ArduinoECCX08,RTCZero

src/AIoTC_Config.h

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,65 @@
3030
#define NTP_USE_RANDOM_PORT (1)
3131
#endif
3232

33-
#ifndef DBG_ERROR
34-
#define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
33+
#ifndef DEBUG_ERROR
34+
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
35+
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
36+
# else
37+
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
38+
# endif
3539
#endif
3640

37-
#ifndef DBG_WARNING
38-
#define DBG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
41+
#ifndef DEBUG_WARNING
42+
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
43+
# define DEBUG_WARNING(fmt, ...)
44+
# else
45+
# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
46+
# endif
3947
#endif
4048

41-
#ifndef DBG_INFO
42-
#define DBG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
49+
#ifndef DEBUG_INFO
50+
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
51+
# define DEBUG_INFO(fmt, ...)
52+
# else
53+
# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
54+
# endif
4355
#endif
4456

45-
#ifndef DBG_DEBUG
46-
#define DBG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
57+
#ifndef DEBUG_DEBUG
58+
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
59+
# define DEBUG_DEBUG(fmt, ...)
60+
# else
61+
# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
62+
# endif
4763
#endif
4864

49-
#ifndef DBG_VERBOSE
50-
#define DBG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
65+
#ifndef DEBUG_VERBOSE
66+
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
67+
# define DEBUG_VERBOSE(fmt, ...)
68+
# else
69+
# define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
70+
# endif
71+
#endif
72+
73+
#if defined(ARDUINO_AVR_UNO_WIFI_REV2) && !(defined(DEBUG_ERROR) || defined(DEBUG_WARNING) || defined(DEBUG_INFO) || defined(DEBUG_DEBUG) || defined(DEBUG_VERBOSE))
74+
/* Provide defines for constants provided within Arduino_DebugUtils
75+
* in order to allow older sketches using those constants to still
76+
* compile.
77+
*/
78+
# define DBG_NONE -1
79+
# define DBG_ERROR 0
80+
# define DBG_WARNING 1
81+
# define DBG_INFO 2
82+
# define DBG_DEBUG 3
83+
# define DBG_VERBOSE 4
5184
#endif
5285

5386
/******************************************************************************
5487
* AUTOMATICALLY CONFIGURED DEFINES
5588
******************************************************************************/
5689

57-
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
90+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
91+
defined(ARDUINO_AVR_UNO_WIFI_REV2)
5892
#define OTA_STORAGE_SNU (1)
5993
#else
6094
#define OTA_STORAGE_SNU (0)
@@ -66,20 +100,25 @@
66100
#define OTA_STORAGE_SSU (0)
67101
#endif
68102

69-
#if OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU
103+
#if (OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU) && !defined(ARDUINO_AVR_UNO_WIFI_REV2)
70104
#define OTA_ENABLED (1)
71105
#else
72106
#define OTA_ENABLED (0)
73107
#endif
74108

75-
#if defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWIFI1010) || \
76-
defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
109+
#if defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKR1000) || \
77110
defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_PORTENTA_H7_M7) || \
78111
defined(ARDUINO_PORTENTA_H7_M4)
79112
#define BOARD_HAS_ECCX08
80113
#define HAS_TCP
81114
#endif
82115

116+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
117+
defined(ARDUINO_AVR_UNO_WIFI_REV2)
118+
#define BOARD_HAS_OFFLOADED_ECCX08
119+
#define HAS_TCP
120+
#endif
121+
83122
#if defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310)
84123
#define HAS_LORA
85124
#endif

src/ArduinoIoTCloud.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,8 @@ void ArduinoIoTCloudClass::execCloudEventCallback(ArduinoIoTCloudEvent const eve
179179
(*callback)();
180180
}
181181
}
182+
183+
__attribute__((weak)) void setDebugMessageLevel(int const /* level */)
184+
{
185+
/* do nothing */
186+
}

src/ArduinoIoTCloud.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
#include <AIoTC_Config.h>
2626

2727
#include <Arduino_ConnectionHandler.h>
28-
#include <Arduino_DebugUtils.h>
28+
29+
#if defined(DEBUG_ERROR) || defined(DEBUG_WARNING) || defined(DEBUG_INFO) || defined(DEBUG_DEBUG) || defined(DEBUG_VERBOSE)
30+
# include <Arduino_DebugUtils.h>
31+
#endif
2932

3033
#include "AIoTC_Const.h"
3134

@@ -154,4 +157,7 @@ class ArduinoIoTCloudClass
154157
#include "ArduinoIoTCloudLPWAN.h"
155158
#endif
156159

160+
// declaration for boards without debug library
161+
void setDebugMessageLevel(int const level);
162+
157163
#endif

src/ArduinoIoTCloudLPWAN.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ void ArduinoIoTCloudLPWAN::update()
8787

8888
void ArduinoIoTCloudLPWAN::printDebugInfo()
8989
{
90-
DBG_INFO(F("***** Arduino IoT Cloud LPWAN - configuration info *****"));
91-
DBG_INFO(F("Thing ID: %s"), getThingId().c_str());
90+
DEBUG_INFO("***** Arduino IoT Cloud LPWAN - configuration info *****");
91+
DEBUG_INFO("Thing ID: %s", getThingId().c_str());
9292
}
9393

9494
/******************************************************************************
@@ -106,16 +106,16 @@ ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_ConnectPhy()
106106
ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_SyncTime()
107107
{
108108
unsigned long const internal_posix_time = _time_service.getTime();
109-
DBG_VERBOSE(F("ArduinoIoTCloudLPWAN::%s internal clock configured to posix timestamp %d"), __FUNCTION__, internal_posix_time);
110-
DBG_INFO(F("Connected to Arduino IoT Cloud"));
109+
DEBUG_VERBOSE("ArduinoIoTCloudLPWAN::%s internal clock configured to posix timestamp %d", __FUNCTION__, internal_posix_time);
110+
DEBUG_INFO("Connected to Arduino IoT Cloud");
111111
return State::Connected;
112112
}
113113

114114
ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_Connected()
115115
{
116116
if (!connected())
117117
{
118-
DBG_ERROR(F("ArduinoIoTCloudLPWAN::%s connection to gateway lost"), __FUNCTION__);
118+
DEBUG_ERROR("ArduinoIoTCloudLPWAN::%s connection to gateway lost", __FUNCTION__);
119119
return State::ConnectPhy;
120120
}
121121

@@ -175,4 +175,4 @@ int ArduinoIoTCloudLPWAN::writeProperties(const byte data[], int length)
175175

176176
ArduinoIoTCloudLPWAN ArduinoCloud;
177177

178-
#endif
178+
#endif

0 commit comments

Comments
 (0)