Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 016e0fe

Browse files
committedJul 25, 2024·
feat: ArduinoIoTCloudNotecard
1 parent ae0194d commit 016e0fe

27 files changed

+849
-70
lines changed
 

‎examples/ArduinoIoTCloud-Advanced/ArduinoIoTCloud-Advanced.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
33
44
IMPORTANT:
5-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
5+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
66
On a LoRa board, if it is configured as a class A device (default and preferred option),
77
values from Cloud dashboard are received only after a value is sent to Cloud.
88

‎examples/ArduinoIoTCloud-Advanced/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/ArduinoIoTCloud-Advanced/thingProperties.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,6 +11,14 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(USE_NOTECARD)
15+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
16+
* or UART. An empty string (or the default value provided below) will not
17+
* override the Notecard's existing configuration.
18+
* Learn more at: https://dev.blues.io */
19+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
20+
#endif
21+
1422
void onSwitchButtonChange();
1523
void onColorChange();
1624

@@ -23,7 +31,7 @@ void initProperties() {
2331
ArduinoCloud.setBoardId(BOARD_ID);
2432
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2533
#endif
26-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
34+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
2735
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
2836
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);
2937
ArduinoCloud.addProperty(color, Permission::ReadWrite).onUpdate(onColorChange);
@@ -34,7 +42,9 @@ void initProperties() {
3442
#endif
3543
}
3644

37-
#if defined(BOARD_HAS_WIFI)
45+
#if defined(USE_NOTECARD)
46+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
47+
#elif defined(BOARD_HAS_WIFI)
3848
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
3949
#elif defined(BOARD_HAS_GSM)
4050
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

‎examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
77
88
IMPORTANT:
9-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
9+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
1010
On a LoRa board, if it is configured as a class A device (default and preferred option),
1111
values from Cloud dashboard are received only after a value is sent to Cloud.
1212

‎examples/ArduinoIoTCloud-Basic/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/ArduinoIoTCloud-Basic/thingProperties.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,6 +11,14 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(USE_NOTECARD)
15+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
16+
* or UART. An empty string (or the default value provided below) will not
17+
* override the Notecard's existing configuration.
18+
* Learn more at: https://dev.blues.io */
19+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
20+
#endif
21+
1422
void onLedChange();
1523

1624
bool led;
@@ -26,14 +34,16 @@ void initProperties() {
2634
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
2735
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
2836
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
29-
#elif defined(BOARD_HAS_LORA)
37+
#elif defined(USE_NOTECARD) || defined(BOARD_HAS_LORA)
3038
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
3139
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
3240
ArduinoCloud.addProperty(seconds, 3, Permission::Read).publishEvery(5 * MINUTES);
3341
#endif
3442
}
3543

36-
#if defined(BOARD_HAS_ETHERNET)
44+
#if defined(USE_NOTECARD)
45+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
46+
#elif defined(BOARD_HAS_ETHERNET)
3747
/* DHCP mode */
3848
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
3949
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */

‎examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
One function per event can be assigned.
1919
2020
IMPORTANT:
21-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
21+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
2222
On a LoRa board, if it is configured as a class A device (default and preferred option),
2323
values from Cloud dashboard are received only after a value is sent to Cloud.
2424

‎examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/ArduinoIoTCloud-Callbacks/thingProperties.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,14 +11,24 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(USE_NOTECARD)
15+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
16+
* or UART. An empty string (or the default value provided below) will not
17+
* override the Notecard's existing configuration.
18+
* Learn more at: https://dev.blues.io */
19+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
20+
#endif
21+
1422
void initProperties() {
1523
#if defined(BOARD_HAS_SECRET_KEY)
1624
ArduinoCloud.setBoardId(BOARD_ID);
1725
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1826
#endif
1927
}
2028

21-
#if defined(BOARD_HAS_WIFI)
29+
#if defined(USE_NOTECARD)
30+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
31+
#elif defined(BOARD_HAS_WIFI)
2232
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
2333
#elif defined(BOARD_HAS_GSM)
2434
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

‎examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/ArduinoIoTCloud-Schedule/ArduinoIoTCloud-Schedule.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This sketch demonstrates how to use the cloud schedule variable type.
33
44
IMPORTANT:
5-
This sketch works with WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.
5+
This sketch works with Notecard, WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.
66
77
*/
88

‎examples/ArduinoIoTCloud-Schedule/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/ArduinoIoTCloud-Schedule/thingProperties.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -11,6 +11,14 @@
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

14+
#if defined(USE_NOTECARD)
15+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
16+
* or UART. An empty string (or the default value provided below) will not
17+
* override the Notecard's existing configuration.
18+
* Learn more at: https://dev.blues.io */
19+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
20+
#endif
21+
1422
void onSwitchButtonChange();
1523

1624
bool switchButton;
@@ -27,7 +35,7 @@ void initProperties() {
2735
ArduinoCloud.setBoardId(BOARD_ID);
2836
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2937
#endif
30-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
38+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
3139
ArduinoCloud.addProperty(switchButton, Permission::Write);
3240
ArduinoCloud.addProperty(oneShot, Permission::ReadWrite);
3341
ArduinoCloud.addProperty(minute, Permission::ReadWrite);
@@ -41,7 +49,9 @@ void initProperties() {
4149
#endif
4250
}
4351

44-
#if defined(BOARD_HAS_WIFI)
52+
#if defined(USE_NOTECARD)
53+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
54+
#elif defined(BOARD_HAS_WIFI)
4555
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
4656
#elif defined(BOARD_HAS_GSM)
4757
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);

‎examples/utility/ArduinoIoTCloud_Travis_CI/ArduinoIoTCloud_Travis_CI.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Arduino IoT Cloud API.
55
66
IMPORTANT:
7-
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
7+
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
88
On a LoRa board, if it is configured as a class A device (default and preferred option),
99
values from Cloud dashboard are received only after a value is sent to Cloud.
1010

‎examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* A complete list of supported boards with WiFi is available here:
44
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
55
*/
6-
#if defined(BOARD_HAS_WIFI)
6+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI)
77
#define SECRET_WIFI_SSID "YOUR_WIFI_NETWORK_NAME"
88
#define SECRET_WIFI_PASS "YOUR_WIFI_PASSWORD"
99
#endif

‎examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <Arduino_ConnectionHandler.h>
33
#include "arduino_secrets.h"
44

5-
#if !(defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
5+
#if !(defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_LORA) || \
66
defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT))
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
@@ -19,6 +19,14 @@
1919
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
2020
#endif
2121

22+
#if defined(USE_NOTECARD)
23+
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
24+
* or UART. An empty string (or the default value provided below) will not
25+
* override the Notecard's existing configuration.
26+
* Learn more at: https://dev.blues.io */
27+
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
28+
#endif
29+
2230
/******************************************************************************
2331
GLOBAL CONSTANTS
2432
******************************************************************************/
@@ -54,7 +62,9 @@ String str_property_6;
5462
String str_property_7;
5563
String str_property_8;
5664

57-
#if defined(BOARD_HAS_WIFI)
65+
#if defined(USE_NOTECARD)
66+
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
67+
#elif defined(BOARD_HAS_WIFI)
5868
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
5969
#elif defined(BOARD_HAS_GSM)
6070
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
@@ -83,7 +93,7 @@ void onStringPropertyChange();
8393
/******************************************************************************
8494
FUNCTIONS
8595
******************************************************************************/
86-
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB) || defined (BOARD_HAS_CATM1_NBIOT)
96+
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB) || defined (BOARD_HAS_CATM1_NBIOT)
8797
void initProperties() {
8898
#if defined(BOARD_HAS_SECRET_KEY)
8999
ArduinoCloud.setBoardId(BOARD_ID);

‎library.properties

Lines changed: 1 addition & 1 deletion
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,renesas_uno,mbed_edge
9+
architectures=mbed,samd,esp8266,mbed_nano,mbed_portenta,mbed_nicla,esp32,mbed_opta,mbed_giga,renesas_portenta,renesas_uno,mbed_edge,stm32
1010
includes=ArduinoIoTCloud.h
1111
depends=Arduino_ConnectionHandler,Arduino_DebugUtils,Arduino_SecureElement,ArduinoMqttClient,ArduinoECCX08,RTCZero,Adafruit SleepyDog Library,ArduinoHttpClient

‎src/AIoTC_Config.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#ifndef ARDUINO_AIOTC_CONFIG_H_
1919
#define ARDUINO_AIOTC_CONFIG_H_
2020

21+
#if defined __has_include
22+
#if __has_include (<Notecard.h>)
23+
#define USE_NOTECARD
24+
#endif
25+
#endif
26+
2127
#include <ArduinoECCX08Config.h>
2228

2329
/******************************************************************************
@@ -52,6 +58,8 @@
5258
* AUTOMATICALLY CONFIGURED DEFINES
5359
******************************************************************************/
5460

61+
#if !defined(USE_NOTECARD)
62+
5563
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
5664
#define OTA_STORAGE_SNU (1)
5765
#else
@@ -114,11 +122,6 @@
114122
#define HAS_TCP
115123
#endif
116124

117-
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_OPTA) || defined(ARDUINO_GIGA)
118-
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
119-
#define BOARD_STM32H7
120-
#endif
121-
122125
#if defined(ARDUINO_NANO_RP2040_CONNECT)
123126
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
124127
#endif
@@ -138,6 +141,13 @@
138141
#define BOARD_HAS_SECURE_ELEMENT
139142
#endif
140143

144+
#endif // USE_NOTECARD
145+
146+
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_OPTA) || defined(ARDUINO_GIGA)
147+
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
148+
#define BOARD_STM32H7
149+
#endif
150+
141151
/******************************************************************************
142152
* CONSTANTS
143153
******************************************************************************/
@@ -146,7 +156,7 @@
146156
#define AIOT_CONFIG_LPWAN_UPDATE_RETRY_DELAY_ms (10000UL)
147157
#endif
148158

149-
#if defined(HAS_TCP)
159+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
150160
#define AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms (1000UL)
151161
#define AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms (32000UL)
152162

‎src/ArduinoIoTCloud.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ class ArduinoIoTCloudClass
161161
OnCloudEventCallback _cloud_event_callback[3];
162162
};
163163

164-
#ifdef HAS_TCP
164+
#if defined(USE_NOTECARD)
165+
#include "ArduinoIoTCloudNotecard.h"
166+
#elif defined(HAS_TCP)
165167
#include "ArduinoIoTCloudTCP.h"
166168
#elif defined(HAS_LORA)
167169
#include "ArduinoIoTCloudLPWAN.h"

‎src/ArduinoIoTCloudDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <AIoTC_Config.h>
1616

17-
#ifdef HAS_TCP
17+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
1818

1919
#include "ArduinoIoTCloudDevice.h"
2020
#include "interfaces/CloudProcess.h"
@@ -146,4 +146,4 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleDisconnected() {
146146
return State::Disconnected;
147147
}
148148

149-
#endif /* HAS_TCP */
149+
#endif /* USE_NOTECARD || HAS_TCP */

‎src/ArduinoIoTCloudNotecard.cpp

Lines changed: 552 additions & 0 deletions
Large diffs are not rendered by default.

‎src/ArduinoIoTCloudNotecard.h

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
This file is part of ArduinoIoTCloud.
3+
4+
Copyright 2024 Blues (http://www.blues.com/)
5+
6+
This software is released under the GNU General Public License version 3,
7+
which covers the main part of arduino-cli.
8+
The terms of this license can be found at:
9+
https://www.gnu.org/licenses/gpl-3.0.en.html
10+
11+
You can be released from the requirements of the above licenses by purchasing
12+
a commercial license. Buying such a license is mandatory if you want to
13+
modify or otherwise use the software for commercial activities involving the
14+
Arduino software without disclosing the source code of your own applications.
15+
To purchase a commercial license, send an email to license@arduino.cc.
16+
*/
17+
18+
#ifndef ARDUINO_IOT_CLOUD_NOTECARD_H
19+
#define ARDUINO_IOT_CLOUD_NOTECARD_H
20+
21+
/******************************************************************************
22+
* INCLUDE
23+
******************************************************************************/
24+
25+
#include "ArduinoIoTCloud.h"
26+
#include "ArduinoIoTCloudThing.h"
27+
#include "ArduinoIoTCloudDevice.h"
28+
29+
/******************************************************************************
30+
* DEFINES
31+
******************************************************************************/
32+
33+
#define USE_LIGHT_PAYLOADS (false)
34+
35+
/******************************************************************************
36+
* CONSTANTS
37+
******************************************************************************/
38+
39+
/******************************************************************************
40+
* TYPEDEF
41+
******************************************************************************/
42+
43+
#if OTA_ENABLED
44+
typedef bool (*onOTARequestCallbackFunc)(void);
45+
#endif /* OTA_ENABLED */
46+
47+
/******************************************************************************
48+
* CLASS DECLARATION
49+
******************************************************************************/
50+
51+
class ArduinoIoTCloudNotecard : public ArduinoIoTCloudClass
52+
{
53+
public:
54+
ArduinoIoTCloudNotecard();
55+
virtual ~ArduinoIoTCloudNotecard() { }
56+
57+
virtual void update () override;
58+
virtual int connected () override;
59+
virtual void printDebugInfo() override;
60+
inline virtual PropertyContainer &getThingPropertyContainer() override { return _thing.getPropertyContainer(); }
61+
62+
int begin(ConnectionHandler &connection, int interrupt_pin = -1);
63+
64+
#ifdef BOARD_HAS_SECRET_KEY
65+
inline void setBoardId (String const & device_id) { (_connection && (NetworkConnectionState::INIT != _connection->check())) ? setDeviceId(reinterpret_cast<NotecardConnectionHandler *>(_connection)->syncArduinoDeviceId(device_id)) : setDeviceId(device_id); }
66+
inline void setSecretDeviceKey(String const & secret_device_key) { _secret_device_key = secret_device_key; }
67+
#endif
68+
69+
private:
70+
71+
enum class State
72+
{
73+
ConnectPhy,
74+
SyncTime,
75+
ConfigureNotehub,
76+
Connected,
77+
Disconnect,
78+
};
79+
80+
State _state;
81+
TimedAttempt _connection_attempt;
82+
MessageStream _message_stream;
83+
ArduinoCloudThing _thing;
84+
ArduinoCloudDevice _device;
85+
86+
// Notecard member variables
87+
uint32_t _last_poll_ms;
88+
int _interrupt_pin;
89+
volatile bool _data_available;
90+
91+
#ifdef BOARD_HAS_SECRET_KEY
92+
String _secret_device_key;
93+
#endif
94+
95+
#if OTA_ENABLED
96+
// OTA member variables
97+
bool _ota_cap;
98+
int _ota_error;
99+
String _ota_img_sha256;
100+
String _ota_url;
101+
bool _ota_req;
102+
bool _ask_user_before_executing_ota;
103+
onOTARequestCallbackFunc _get_ota_confirmation;
104+
#endif /* OTA_ENABLED */
105+
106+
State handle_ConnectPhy();
107+
State handle_SyncTime();
108+
State handle_ConfigureNotehub();
109+
State handle_Connected();
110+
State handle_Disconnect();
111+
112+
void attachThing(String thingId);
113+
bool available (void);
114+
#if OTA_ENABLED
115+
void checkOTARequest(void);
116+
#endif /* OTA_ENABLED */
117+
void detachThing();
118+
void fetchIncomingBytes(uint8_t *buf, size_t &len);
119+
void pollNotecard(void);
120+
void processCommand(const uint8_t *buf, size_t len);
121+
void processMessage(const uint8_t *buf, size_t len);
122+
void requestThingIdFromNotehub(void);
123+
void sendMessage(Message * msg);
124+
void sendCommandMsgToCloud(Message * msg_);
125+
void sendThingPropertyContainerToCloud(void);
126+
127+
friend void ISR_dataAvailable (void);
128+
};
129+
130+
/******************************************************************************
131+
* EXTERN DECLARATION
132+
******************************************************************************/
133+
134+
extern ArduinoIoTCloudNotecard ArduinoCloud;
135+
136+
#endif

‎src/ArduinoIoTCloudThing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <AIoTC_Config.h>
1717

18-
#ifdef HAS_TCP
18+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
1919

2020
#include "ArduinoIoTCloudThing.h"
2121
#include "interfaces/CloudProcess.h"
@@ -180,4 +180,4 @@ ArduinoCloudThing::State ArduinoCloudThing::handleDisconnect() {
180180
return State::Disconnect;
181181
}
182182

183-
#endif /* HAS_TCP */
183+
#endif /* USE_NOTECARD || HAS_TCP */

‎src/utility/time/RTCMillis.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
a commercial license, send an email to license@arduino.cc.
1616
*/
1717

18-
#ifdef ARDUINO_ARCH_ESP8266
19-
2018
/**************************************************************************************
2119
* INCLUDE
2220
**************************************************************************************/
2321

22+
#include "AIoTC_Config.h"
23+
24+
#if defined(USE_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
25+
2426
#include <Arduino.h>
2527
#include "RTCMillis.h"
2628

@@ -59,4 +61,4 @@ unsigned long RTCMillis::get()
5961
return _last_rtc_update_value;
6062
}
6163

62-
#endif /* ARDUINO_ARCH_ESP8266 */
64+
#endif /* USE_NOTECARD || ARDUINO_ARCH_ESP8266 */

‎src/utility/time/RTCMillis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifndef ARDUINO_IOT_CLOUD_RTC_MILLIS_H_
1919
#define ARDUINO_IOT_CLOUD_RTC_MILLIS_H_
2020

21-
#ifdef ARDUINO_ARCH_ESP8266
21+
#if defined(USE_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
2222

2323
/**************************************************************************************
2424
* INCLUDE
@@ -45,6 +45,6 @@ class RTCMillis
4545

4646
};
4747

48-
#endif /* ARDUINO_ARCH_ESP8266 */
48+
#endif /* USE_NOTECARD || ARDUINO_ARCH_ESP8266 */
4949

5050
#endif /* ARDUINO_IOT_CLOUD_RTC_MILLIS_H_ */

‎src/utility/time/TimeService.cpp

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,32 @@
1919
* INCLUDE
2020
**************************************************************************************/
2121

22-
#include <AIoTC_Config.h>
2322

2423
#include <time.h>
25-
#include "TimeService.h"
26-
#include "NTPUtils.h"
24+
25+
#include "AIoTC_Config.h"
2726
#include "AIoTC_Const.h"
27+
#include "NTPUtils.h"
28+
#include "TimeService.h"
2829

29-
#ifdef ARDUINO_ARCH_SAMD
30+
#if defined(USE_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
31+
#include "RTCMillis.h"
32+
#elif defined(ARDUINO_ARCH_SAMD)
3033
#include <RTCZero.h>
31-
#endif
32-
33-
#ifdef ARDUINO_ARCH_MBED
34+
#elif defined(ARDUINO_ARCH_MBED)
3435
#include <mbed_rtc_time.h>
35-
#endif
36-
37-
#ifdef ARDUINO_ARCH_ESP8266
38-
#include "RTCMillis.h"
39-
#endif
40-
41-
#ifdef ARDUINO_ARCH_RENESAS
36+
#elif defined(ARDUINO_ARCH_RENESAS)
4237
#include "RTC.h"
4338
#endif
4439

4540
/**************************************************************************************
4641
* GLOBAL VARIABLES
4742
**************************************************************************************/
4843

49-
#ifdef ARDUINO_ARCH_SAMD
50-
RTCZero rtc;
51-
#endif
52-
53-
#ifdef ARDUINO_ARCH_ESP8266
44+
#if defined(USE_NOTECARD) || defined(ARDUINO_ARCH_ESP8266)
5445
RTCMillis rtc;
46+
#elif defined(ARDUINO_ARCH_SAMD)
47+
RTCZero rtc;
5548
#endif
5649

5750
/**************************************************************************************
@@ -60,6 +53,12 @@ RTCMillis rtc;
6053

6154
time_t cvt_time(char const * time);
6255

56+
#if defined(USE_NOTECARD)
57+
void notecard_initRTC();
58+
void notecard_setRTC(unsigned long time);
59+
unsigned long notecard_getRTC();
60+
#else
61+
6362
#ifdef ARDUINO_ARCH_SAMD
6463
void samd_initRTC();
6564
void samd_setRTC(unsigned long time);
@@ -90,6 +89,8 @@ void renesas_setRTC(unsigned long time);
9089
unsigned long renesas_getRTC();
9190
#endif
9291

92+
#endif /* USE_NOTECARD */
93+
9394
/**************************************************************************************
9495
* DEFINES
9596
**************************************************************************************/
@@ -161,10 +162,9 @@ bool TimeServiceClass::sync()
161162
if(_sync_func) {
162163
utc = _sync_func();
163164
} else {
164-
#ifdef HAS_TCP
165+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
165166
utc = getRemoteTime();
166-
#endif
167-
#ifdef HAS_LORA
167+
#elif defined(HAS_LORA)
168168
/* Just keep incrementing stored RTC value*/
169169
utc = getRTC();
170170
#endif
@@ -275,7 +275,7 @@ unsigned long TimeServiceClass::getTimeFromString(const String& input)
275275
* PRIVATE MEMBER FUNCTIONS
276276
**************************************************************************************/
277277

278-
#ifdef HAS_TCP
278+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
279279
bool TimeServiceClass::connected()
280280
{
281281
if(_con_hdl == nullptr) {
@@ -288,6 +288,7 @@ bool TimeServiceClass::connected()
288288
unsigned long TimeServiceClass::getRemoteTime()
289289
{
290290
if(connected()) {
291+
#ifdef HAS_TCP
291292
/* At first try to obtain a valid time via NTP.
292293
* This is the most reliable time source and it will
293294
* ensure a correct behaviour of the library.
@@ -298,6 +299,7 @@ unsigned long TimeServiceClass::getRemoteTime()
298299
return ntp_time;
299300
}
300301
}
302+
#endif /* HAS_TCP */
301303

302304
/* As fallback if NTP request fails try to obtain the
303305
* network time using the connection handler.
@@ -316,7 +318,7 @@ unsigned long TimeServiceClass::getRemoteTime()
316318
return EPOCH_AT_COMPILE_TIME;
317319
}
318320

319-
#endif /* HAS_TCP */
321+
#endif /* USE_NOTECARD || HAS_TCP */
320322

321323
bool TimeServiceClass::isTimeValid(unsigned long const time)
322324
{
@@ -331,7 +333,9 @@ bool TimeServiceClass::isTimeZoneOffsetValid(long const offset)
331333

332334
void TimeServiceClass::initRTC()
333335
{
334-
#if defined (ARDUINO_ARCH_SAMD)
336+
#if defined (USE_NOTECARD)
337+
notecard_initRTC();
338+
#elif defined (ARDUINO_ARCH_SAMD)
335339
samd_initRTC();
336340
#elif defined (ARDUINO_ARCH_MBED)
337341
mbed_initRTC();
@@ -348,7 +352,9 @@ void TimeServiceClass::initRTC()
348352

349353
void TimeServiceClass::setRTC(unsigned long time)
350354
{
351-
#if defined (ARDUINO_ARCH_SAMD)
355+
#if defined (USE_NOTECARD)
356+
notecard_setRTC(time);
357+
#elif defined (ARDUINO_ARCH_SAMD)
352358
samd_setRTC(time);
353359
#elif defined (ARDUINO_ARCH_MBED)
354360
mbed_setRTC(time);
@@ -365,7 +371,9 @@ void TimeServiceClass::setRTC(unsigned long time)
365371

366372
unsigned long TimeServiceClass::getRTC()
367373
{
368-
#if defined (ARDUINO_ARCH_SAMD)
374+
#if defined (USE_NOTECARD)
375+
return notecard_getRTC();
376+
#elif defined (ARDUINO_ARCH_SAMD)
369377
return samd_getRTC();
370378
#elif defined (ARDUINO_ARCH_MBED)
371379
return mbed_getRTC();
@@ -420,6 +428,23 @@ time_t cvt_time(char const * time)
420428
return build_time;
421429
}
422430

431+
#ifdef USE_NOTECARD
432+
void notecard_initRTC()
433+
{
434+
rtc.begin();
435+
}
436+
437+
void notecard_setRTC(unsigned long time)
438+
{
439+
rtc.set(time);
440+
}
441+
442+
unsigned long notecard_getRTC()
443+
{
444+
return rtc.get();
445+
}
446+
#else
447+
423448
#ifdef ARDUINO_ARCH_SAMD
424449
void samd_initRTC()
425450
{
@@ -509,6 +534,8 @@ unsigned long renesas_getRTC()
509534
}
510535
#endif
511536

537+
#endif /* USE_NOTECARD */
538+
512539
/******************************************************************************
513540
* EXTERN DEFINITION
514541
******************************************************************************/

‎src/utility/time/TimeService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TimeServiceClass
6969
unsigned long _sync_interval_ms;
7070
syncTimeFunctionPtr _sync_func;
7171

72-
#ifdef HAS_TCP
72+
#if defined(USE_NOTECARD) || defined(HAS_TCP)
7373
unsigned long getRemoteTime();
7474
bool connected();
7575
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.