Skip to content

Library examples cleanup and adjust #341

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 7 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.

This sketch is compatible with:
- MKR 1000
- MKR WiFi 1010
- MKR GSM 1400
- MKR NB 1500
- MKR WAN 1300/1310
- Nano 33 IoT
- ESP8266
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
Expand Down
9 changes: 6 additions & 3 deletions examples/ArduinoIoTCloud-Advanced/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
#if defined(BOARD_ESP8266)
/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
15 changes: 11 additions & 4 deletions examples/ArduinoIoTCloud-Advanced/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void onSwitchButtonChange();
void onColorChange();
Expand All @@ -11,7 +18,7 @@ CloudLocation location;
CloudColor color;

void initProperties() {
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
8 changes: 1 addition & 7 deletions examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
only after a value is sent to Cloud.

This sketch is compatible with:
- MKR 1000
- MKR WiFi 1010
- MKR GSM 1400
- MKR NB 1500
- MKR WAN 1300/1310
- Nano 33 IoT
- ESP8266
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

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

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
11 changes: 5 additions & 6 deletions examples/ArduinoIoTCloud-Basic/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void onLedChange();

Expand All @@ -18,7 +17,7 @@ int potentiometer;
int seconds;

void initProperties() {
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
only after a value is sent to Cloud.

This sketch is compatible with:
- MKR 1000
- MKR WiFi 1010
- MKR GSM 1400
- MKR NB 1500
- MKR WAN 1300/1310
- Nano 33 IoT
- ESP8266
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
Expand Down
9 changes: 6 additions & 3 deletions examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
#if defined(BOARD_ESP8266)
/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
12 changes: 5 additions & 7 deletions examples/ArduinoIoTCloud-Callbacks/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

/* BOARD_ID is only required if you are using an ESP8266 */
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void initProperties() {
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
* ask_user_via_serial callback will read user input from serial to apply or postpone OTA update

This sketch is compatible with:
- MKR WiFi 1010
- Nano 33 IoT
- Portenta
- Nano RP2040
- https://github.com/arduino-libraries/ArduinoIoTCloud/#ota
*/

#include "arduino_secrets.h"
Expand Down
9 changes: 6 additions & 3 deletions examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
#if defined(BOARD_ESP8266)
/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
11 changes: 5 additions & 6 deletions examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void onLedChange();

bool led;

void initProperties() {
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
This sketch demonstrates how to use the cloud schedule variable type.

This sketch is compatible with the following boards:
- MKR 1000
- MKR WiFi 1010
- MKR GSM 1400
- MKR NB 1500
- Nano 33 IoT
- ESP8266
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

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

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 */
#if defined(BOARD_ESP8266)
/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
15 changes: 11 additions & 4 deletions examples/ArduinoIoTCloud-Schedule/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void onSwitchButtonChange();

Expand All @@ -15,7 +22,7 @@ CloudSchedule monthly;
CloudSchedule yearly;

void initProperties() {
#if defined(BOARD_ESP8266)
#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
Arduino IoT Cloud API.

This sketch is compatible with:
- MKR 1000
- MKR WIFI 1010
- MKR GSM 1400
- MKR WAN 1300/1310
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
*/

#include "arduino_secrets.h"
Expand Down
10 changes: 9 additions & 1 deletion examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

/* MKR1000, MKR WiFi 1010 */
/* A complete list of supported boards with WiFi is available here:
* https://github.com/arduino-libraries/ArduinoIoTCloud/#what
*/
#if defined(BOARD_HAS_WIFI)
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

/* MKR GSM 1400 */
#if defined(BOARD_HAS_GSM)
#define SECRET_PIN ""
Expand Down
22 changes: 13 additions & 9 deletions examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/******************************************************************************
INCLUDE
******************************************************************************/

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

#if defined(BOARD_HAS_WIFI)
#elif defined(BOARD_HAS_GSM)
#elif defined(BOARD_HAS_LORA)
#elif defined(BOARD_HAS_NB)
#else
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

/******************************************************************************
DEFINES
******************************************************************************/

#if defined(BOARD_ESP)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

/******************************************************************************
Expand Down Expand Up @@ -72,7 +73,10 @@ void onStringPropertyChange();
******************************************************************************/
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB)
void initProperties() {

#if defined(BOARD_ESP)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
ArduinoCloud.addProperty(bool_property_1, READWRITE, 1 * SECONDS);
ArduinoCloud.addProperty(int_property_1, READ, 2 * MINUTES);
ArduinoCloud.addProperty(float_property_1, WRITE, 3 * HOURS);
Expand Down