Skip to content

Commit

Permalink
feat: ArduinoIoTCloudNotecard
Browse files Browse the repository at this point in the history
  • Loading branch information
zfields committed Jul 20, 2024
1 parent 8b6ff40 commit 3d8e710
Show file tree
Hide file tree
Showing 20 changed files with 830 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option),
values from Cloud dashboard are received only after a value is sent to Cloud.
Expand Down
16 changes: 13 additions & 3 deletions examples/ArduinoIoTCloud-Advanced/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

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

#if defined(USE_NOTECARD)
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
* or UART. An empty string (or the default value provided below) will not
* override the Notecard's existing configuration.
* Learn more at: https://dev.blues.io */
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
#endif

void onSwitchButtonChange();
void onColorChange();

Expand All @@ -23,7 +31,7 @@ void initProperties() {
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
#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)
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);
ArduinoCloud.addProperty(color, Permission::ReadWrite).onUpdate(onColorChange);
Expand All @@ -34,7 +42,9 @@ void initProperties() {
#endif
}

#if defined(BOARD_HAS_WIFI)
#if defined(USE_NOTECARD)
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option),
values from Cloud dashboard are received only after a value is sent to Cloud.
Expand Down
16 changes: 13 additions & 3 deletions examples/ArduinoIoTCloud-Basic/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

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

#if defined(USE_NOTECARD)
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
* or UART. An empty string (or the default value provided below) will not
* override the Notecard's existing configuration.
* Learn more at: https://dev.blues.io */
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
#endif

void onLedChange();

bool led;
Expand All @@ -26,14 +34,16 @@ void initProperties() {
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
#elif defined(BOARD_HAS_LORA)
#elif defined(USE_NOTECARD) || defined(BOARD_HAS_LORA)
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, 3, Permission::Read).publishEvery(5 * MINUTES);
#endif
}

#if defined(BOARD_HAS_ETHERNET)
#if defined(USE_NOTECARD)
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
#elif defined(BOARD_HAS_ETHERNET)
/* DHCP mode */
//EthernetConnectionHandler ArduinoIoTPreferredConnection;
/* Manual mode. It will fallback in DHCP mode if SECRET_OPTIONAL_IP is invalid or equal to "0.0.0.0" */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
One function per event can be assigned.
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option),
values from Cloud dashboard are received only after a value is sent to Cloud.
Expand Down
14 changes: 12 additions & 2 deletions examples/ArduinoIoTCloud-Callbacks/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

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

#if defined(USE_NOTECARD)
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
* or UART. An empty string (or the default value provided below) will not
* override the Notecard's existing configuration.
* Learn more at: https://dev.blues.io */
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
#endif

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
}

#if defined(BOARD_HAS_WIFI)
#if defined(USE_NOTECARD)
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This sketch demonstrates how to use the cloud schedule variable type.
IMPORTANT:
This sketch works with WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.
This sketch works with Notecard, WiFi, GSM, NB and Ethernet enabled boards supported by Arduino IoT Cloud.
*/

Expand Down
16 changes: 13 additions & 3 deletions examples/ArduinoIoTCloud-Schedule/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

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

#if defined(USE_NOTECARD)
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
* or UART. An empty string (or the default value provided below) will not
* override the Notecard's existing configuration.
* Learn more at: https://dev.blues.io */
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
#endif

void onSwitchButtonChange();

bool switchButton;
Expand All @@ -27,7 +35,7 @@ void initProperties() {
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB) || defined(BOARD_HAS_ETHERNET) || defined(BOARD_HAS_CATM1_NBIOT)
#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)
ArduinoCloud.addProperty(switchButton, Permission::Write);
ArduinoCloud.addProperty(oneShot, Permission::ReadWrite);
ArduinoCloud.addProperty(minute, Permission::ReadWrite);
Expand All @@ -41,7 +49,9 @@ void initProperties() {
#endif
}

#if defined(BOARD_HAS_WIFI)
#if defined(USE_NOTECARD)
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Arduino IoT Cloud API.
IMPORTANT:
This sketch works with WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud.
On a LoRa board, if it is configured as a class A device (default and preferred option),
values from Cloud dashboard are received only after a value is sent to Cloud.
Expand Down
16 changes: 13 additions & 3 deletions examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

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

#if defined(USE_NOTECARD)
/* The Notecard can provide connectivity to almost any board via ESLOV (I2C)
* or UART. An empty string (or the default value provided below) will not
* override the Notecard's existing configuration.
* Learn more at: https://dev.blues.io */
#define NOTECARD_PRODUCT_UID "com.domain.you:product"
#endif

/******************************************************************************
GLOBAL CONSTANTS
******************************************************************************/
Expand Down Expand Up @@ -54,7 +62,9 @@ String str_property_6;
String str_property_7;
String str_property_8;

#if defined(BOARD_HAS_WIFI)
#if defined(USE_NOTECARD)
NotecardConnectionHandler ArduinoIoTPreferredConnection(NOTECARD_PRODUCT_UID);
#elif defined(BOARD_HAS_WIFI)
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_SSID, SECRET_WIFI_PASS);
#elif defined(BOARD_HAS_GSM)
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
Expand Down Expand Up @@ -83,7 +93,7 @@ void onStringPropertyChange();
/******************************************************************************
FUNCTIONS
******************************************************************************/
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB) || defined (BOARD_HAS_CATM1_NBIOT)
#if defined(USE_NOTECARD) || defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB) || defined (BOARD_HAS_CATM1_NBIOT)
void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
Expand Down
14 changes: 9 additions & 5 deletions src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
* AUTOMATICALLY CONFIGURED DEFINES
******************************************************************************/

#if !defined(USE_NOTECARD)

#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
#define OTA_STORAGE_SNU (1)
#else
Expand Down Expand Up @@ -114,11 +116,6 @@
#define HAS_TCP
#endif

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_OPTA) || defined(ARDUINO_GIGA)
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
#define BOARD_STM32H7
#endif

#if defined(ARDUINO_NANO_RP2040_CONNECT)
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
#endif
Expand All @@ -138,6 +135,13 @@
#define BOARD_HAS_SECURE_ELEMENT
#endif

#endif // USE_NOTECARD

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_OPTA) || defined(ARDUINO_GIGA)
#define BEAR_SSL_CLIENT_IBUF_SIZE (16384 + 325) // Allows download from storage API
#define BOARD_STM32H7
#endif

/******************************************************************************
* CONSTANTS
******************************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion src/ArduinoIoTCloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ class ArduinoIoTCloudClass
OnCloudEventCallback _cloud_event_callback[3];
};

#ifdef HAS_TCP
#if defined(USE_NOTECARD)
#include "ArduinoIoTCloudNotecard.h"
#elif defined(HAS_TCP)
#include "ArduinoIoTCloudTCP.h"
#elif defined(HAS_LORA)
#include "ArduinoIoTCloudLPWAN.h"
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoIoTCloudDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <AIoTC_Config.h>

#ifdef HAS_TCP
#if defined(USE_NOTECARD) || defined(HAS_TCP)

#include "ArduinoIoTCloudDevice.h"
#include "interfaces/CloudProcess.h"
Expand Down Expand Up @@ -142,4 +142,4 @@ ArduinoCloudDevice::State ArduinoCloudDevice::handleDisconnected() {
return State::Disconnected;
}

#endif /* HAS_TCP */
#endif /* USE_NOTECARD || HAS_TCP */
Loading

0 comments on commit 3d8e710

Please sign in to comment.