Skip to content

Commit

Permalink
examples: use HAS_TCP or HAS_LORA to reduce maintenance efforts
Browse files Browse the repository at this point in the history
  • Loading branch information
pennam committed Aug 14, 2024
1 parent e57ab50 commit bd8de84
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
9 changes: 4 additions & 5 deletions examples/ArduinoIoTCloud-Advanced/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

#if !(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"
#if !(defined(HAS_TCP) || defined(HAS_LORA))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_HAS_SECRET_KEY)
Expand All @@ -23,11 +22,11 @@ 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(HAS_TCP)
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);
ArduinoCloud.addProperty(color, Permission::ReadWrite).onUpdate(onColorChange);
#elif defined(BOARD_HAS_LORA)
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(switchButton, 1, Permission::Write).onUpdate(onSwitchButtonChange);
ArduinoCloud.addProperty(location, 2, Permission::Read).publishOnChange(0.0f);
ArduinoCloud.addProperty(color, 3, Permission::ReadWrite).onUpdate(onColorChange);
Expand Down
9 changes: 4 additions & 5 deletions examples/ArduinoIoTCloud-Basic/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

#if !(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"
#if !(defined(HAS_TCP) || defined(HAS_LORA))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_HAS_SECRET_KEY)
Expand All @@ -22,11 +21,11 @@ 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(HAS_TCP)
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(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);
Expand Down
5 changes: 2 additions & 3 deletions examples/ArduinoIoTCloud-Callbacks/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

#if !(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"
#if !(defined(HAS_TCP) || defined(HAS_LORA))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_HAS_SECRET_KEY)
Expand Down
9 changes: 4 additions & 5 deletions examples/ArduinoIoTCloud-Schedule/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

#if !(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"
#if !(defined(HAS_TCP) || defined(HAS_LORA))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_HAS_SECRET_KEY)
Expand All @@ -27,7 +26,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(HAS_TCP)
ArduinoCloud.addProperty(switchButton, Permission::Write);
ArduinoCloud.addProperty(oneShot, Permission::ReadWrite);
ArduinoCloud.addProperty(minute, Permission::ReadWrite);
Expand All @@ -36,7 +35,7 @@ void initProperties() {
ArduinoCloud.addProperty(weekly, Permission::ReadWrite);
ArduinoCloud.addProperty(monthly, Permission::ReadWrite);
ArduinoCloud.addProperty(yearly, Permission::ReadWrite);
#elif defined(BOARD_HAS_LORA)
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(switchButton, 1, Permission::Write);
#endif
}
Expand Down
11 changes: 5 additions & 6 deletions examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
#include <Arduino_ConnectionHandler.h>
#include "arduino_secrets.h"

#if !(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"
#if !(defined(HAS_TCP) || defined(HAS_LORA))
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

/******************************************************************************
Expand All @@ -15,7 +14,7 @@
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

#if defined(BOARD_HAS_LORA)
#if defined(HAS_LORA)
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand Down Expand Up @@ -85,7 +84,7 @@ void onStringPropertyChange();
/******************************************************************************
FUNCTIONS
******************************************************************************/
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB) || defined (BOARD_HAS_CATM1_NBIOT)
#if defined(HAS_TCP)
void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
Expand Down Expand Up @@ -118,7 +117,7 @@ void initProperties() {
ArduinoCloud.addProperty(str_property_8, Permission::ReadWrite).publishEvery(1 * SECONDS).onSync(DEVICE_WINS);
}

#elif defined(BOARD_HAS_LORA)
#elif defined(HAS_LORA)
void initProperties() {
ArduinoCloud.setThingId(THING_ID);

Expand Down

0 comments on commit bd8de84

Please sign in to comment.