Skip to content

Offload IoT Cloud connection to Nina module #208

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

Merged
merged 26 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3a665ae
Offload SSL Client w/ crypto on Nina modules
facchinm Oct 20, 2020
8482a1a
Initial support for Uno WiFi rev2
facchinm Oct 20, 2020
6bf3889
RFC: calculate SHA256 using ECCx08
facchinm Nov 16, 2020
3a143a7
Reenable OTA for SAMD Nina targets
facchinm Nov 16, 2020
f087d04
OTA: prepare for UNO WiFi rev2
facchinm Nov 16, 2020
cbb745b
Restore SHA256 via bearSSL
facchinm Nov 17, 2020
2b14646
Prevent inclusion of 'Arduino_DebugUtils' on AVR in a more future-pro…
aentinger Nov 18, 2020
41e2392
Renaming all 'DBG_ERROR/WARNING/INFO/DEBUG/VERBOSE macros to DEBUG_ER…
aentinger Nov 18, 2020
3640d4d
Provide DBG_NONE/ERROR/ etc. values in case ArduinoDebugUtils is not …
aentinger Nov 18, 2020
ad74074
Add Uno WiFi Rev2 to "Compile Examples" CI workflow
per1234 Nov 17, 2020
7ed85b0
Force inclusion of Arduino_AVRSTL.
facchinm Nov 18, 2020
1656ab0
Comment parameter out to prevent unused parameter warning. This funct…
aentinger Jan 27, 2021
573ce66
Clearly disabling DEBUG macros for megaavr architecture.
aentinger Jan 27, 2021
956cd77
Correcting debug macros to allow code to compile.
aentinger Jan 27, 2021
958f73e
Eliminating 'F(expr)' macro since it's of no use due to the Neumann a…
aentinger Jan 27, 2021
d9d5066
List 'megaavr' as supported platform.
aentinger Jan 27, 2021
11217fd
As Arduino_AVRSTL is not yet released directly link to the repository.
aentinger Jan 27, 2021
7e3e196
Fixing as-of-yet-not-fixed wrong braces.
aentinger Jan 27, 2021
f9e8540
Cleaning up include structure.
aentinger Jan 27, 2021
b57d900
megaAVR: don't use NTP time fallback
facchinm Jan 27, 2021
4865f50
Add braces to ensure correct order of operant execution.
aentinger Jan 28, 2021
86b1170
Prevent execution of cloud firmware if a nina firmware < 1.4.2 is pre…
aentinger Jan 28, 2021
6e0e75f
Automatically include Arduino_DebugUtils if any of the debug macros i…
aentinger Jan 28, 2021
9b49af2
Enable ERROR message output for Uno WiFi Rev. 2 (how should you be ab…
aentinger Jan 28, 2021
577f305
Bugfix: Don't loop forever, just return 0.
aentinger Jan 28, 2021
8383de1
Shortening error messages to conserve flash and eliminate unneccsary …
aentinger Jan 28, 2021
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
15 changes: 15 additions & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
{"fqbn": "arduino:samd:mkr1000", "type": "mkr1000"},
{"fqbn": "arduino:samd:mkrwifi1010", "type": "nina"},
{"fqbn": "arduino:samd:nano_33_iot", "type": "nina"},
{"fqbn": "arduino:megaavr:uno2018", "type": "megaavr"},
{"fqbn": "arduino:samd:mkrwan1300", "type": "wan"},
{"fqbn": "arduino:samd:mkrgsm1400", "type": "gsm"},
{"fqbn": "arduino:samd:mkrnb1500", "type": "nb"},
Expand Down Expand Up @@ -79,6 +80,20 @@ jobs:
sketch-paths: |
- examples/utility/Provisioning
- examples/utility/SelfProvisioning
# Uno WiFi Rev2
- board:
type: "megaavr"
platforms: |
- name: arduino:megaavr
libraries: |
- name: ArduinoECCX08
- source-url: https://github.com/arduino-libraries/Arduino_AVRSTL.git
- name: WiFiNINA
- name: Arduino_JSON
- name: ArduinoBearSSL
sketch-paths: |
- examples/utility/Provisioning
- examples/utility/SelfProvisioning
# LoRaWAN boards
- board:
type: "wan"
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 to connect 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 MKRGSM, MKR1000 and WiFi101.
category=Communication
url=https://github.com/arduino-libraries/ArduinoIoTCloud
architectures=mbed,samd,esp8266
architectures=mbed,samd,esp8266,megaavr
includes=ArduinoIoTCloud.h
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,ArduinoMqttClient,ArduinoECCX08,RTCZero
67 changes: 53 additions & 14 deletions src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,65 @@
#define NTP_USE_RANDOM_PORT (1)
#endif

#ifndef DBG_ERROR
#define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
#ifndef DEBUG_ERROR
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
# else
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
# endif
#endif

#ifndef DBG_WARNING
#define DBG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
#ifndef DEBUG_WARNING
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_WARNING(fmt, ...)
# else
# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
# endif
#endif

#ifndef DBG_INFO
#define DBG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
#ifndef DEBUG_INFO
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_INFO(fmt, ...)
# else
# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
# endif
#endif

#ifndef DBG_DEBUG
#define DBG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
#ifndef DEBUG_DEBUG
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_DEBUG(fmt, ...)
# else
# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
# endif
#endif

#ifndef DBG_VERBOSE
#define DBG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
#ifndef DEBUG_VERBOSE
# if defined(ARDUINO_AVR_UNO_WIFI_REV2)
# define DEBUG_VERBOSE(fmt, ...)
# else
# define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
# endif
#endif

#if defined(ARDUINO_AVR_UNO_WIFI_REV2) && !(defined(DEBUG_ERROR) || defined(DEBUG_WARNING) || defined(DEBUG_INFO) || defined(DEBUG_DEBUG) || defined(DEBUG_VERBOSE))
/* Provide defines for constants provided within Arduino_DebugUtils
* in order to allow older sketches using those constants to still
* compile.
*/
# define DBG_NONE -1
# define DBG_ERROR 0
# define DBG_WARNING 1
# define DBG_INFO 2
# define DBG_DEBUG 3
# define DBG_VERBOSE 4
#endif

/******************************************************************************
* AUTOMATICALLY CONFIGURED DEFINES
******************************************************************************/

#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
defined(ARDUINO_AVR_UNO_WIFI_REV2)
#define OTA_STORAGE_SNU (1)
#else
#define OTA_STORAGE_SNU (0)
Expand All @@ -66,20 +100,25 @@
#define OTA_STORAGE_SSU (0)
#endif

#if OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU
#if (OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU) && !defined(ARDUINO_AVR_UNO_WIFI_REV2)
#define OTA_ENABLED (1)
#else
#define OTA_ENABLED (0)
#endif

#if defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRWIFI1010) || \
defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
#if defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKR1000) || \
defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_PORTENTA_H7_M7) || \
defined(ARDUINO_PORTENTA_H7_M4)
#define BOARD_HAS_ECCX08
#define HAS_TCP
#endif

#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
defined(ARDUINO_AVR_UNO_WIFI_REV2)
#define BOARD_HAS_OFFLOADED_ECCX08
#define HAS_TCP
#endif

#if defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310)
#define HAS_LORA
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/ArduinoIoTCloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,8 @@ void ArduinoIoTCloudClass::execCloudEventCallback(ArduinoIoTCloudEvent const eve
(*callback)();
}
}

__attribute__((weak)) void setDebugMessageLevel(int const /* level */)
{
/* do nothing */
}
8 changes: 7 additions & 1 deletion src/ArduinoIoTCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
#include <AIoTC_Config.h>

#include <Arduino_ConnectionHandler.h>
#include <Arduino_DebugUtils.h>

#if defined(DEBUG_ERROR) || defined(DEBUG_WARNING) || defined(DEBUG_INFO) || defined(DEBUG_DEBUG) || defined(DEBUG_VERBOSE)
# include <Arduino_DebugUtils.h>
#endif

#include "AIoTC_Const.h"

Expand Down Expand Up @@ -154,4 +157,7 @@ class ArduinoIoTCloudClass
#include "ArduinoIoTCloudLPWAN.h"
#endif

// declaration for boards without debug library
void setDebugMessageLevel(int const level);

#endif
12 changes: 6 additions & 6 deletions src/ArduinoIoTCloudLPWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void ArduinoIoTCloudLPWAN::update()

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

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

ArduinoIoTCloudLPWAN::State ArduinoIoTCloudLPWAN::handle_Connected()
{
if (!connected())
{
DBG_ERROR(F("ArduinoIoTCloudLPWAN::%s connection to gateway lost"), __FUNCTION__);
DEBUG_ERROR("ArduinoIoTCloudLPWAN::%s connection to gateway lost", __FUNCTION__);
return State::ConnectPhy;
}

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

ArduinoIoTCloudLPWAN ArduinoCloud;

#endif
#endif
Loading