Skip to content

Commit 5823642

Browse files
authored
Merge pull request #341 from pennam/cleanup-examples
Library examples cleanup and adjust
2 parents 9da8516 + dfb452a commit 5823642

18 files changed

+94
-86
lines changed

Diff for: examples/ArduinoIoTCloud-Advanced/ArduinoIoTCloud-Advanced.ino

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
33
44
This sketch is compatible with:
5-
- MKR 1000
6-
- MKR WiFi 1010
7-
- MKR GSM 1400
8-
- MKR NB 1500
9-
- MKR WAN 1300/1310
10-
- Nano 33 IoT
11-
- ESP8266
5+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
126
*/
137

148
#include "arduino_secrets.h"

Diff for: examples/ArduinoIoTCloud-Advanced/arduino_secrets.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

9-
/* ESP8266 */
10-
#if defined(BOARD_ESP8266)
12+
/* ESP8266 ESP32*/
13+
#if defined(BOARD_ESP)
1114
#define SECRET_DEVICE_KEY "my-device-password"
1215
#endif
1316

Diff for: examples/ArduinoIoTCloud-Advanced/thingProperties.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
#include <ArduinoIoTCloud.h>
2-
#include <Arduino_ConnectionHandler.h>
1+
#if defined(BOARD_HAS_WIFI)
2+
#elif defined(BOARD_HAS_GSM)
3+
#elif defined(BOARD_HAS_LORA)
4+
#elif defined(BOARD_HAS_NB)
5+
#else
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
7+
#endif
38

4-
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
9+
#if defined(BOARD_ESP)
10+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
11+
#endif
512

613
void onSwitchButtonChange();
714
void onColorChange();
@@ -11,7 +18,7 @@ CloudLocation location;
1118
CloudColor color;
1219

1320
void initProperties() {
14-
#if defined(BOARD_ESP8266)
21+
#if defined(BOARD_ESP)
1522
ArduinoCloud.setBoardId(BOARD_ID);
1623
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1724
#endif

Diff for: examples/ArduinoIoTCloud-Basic/ArduinoIoTCloud-Basic.ino

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
only after a value is sent to Cloud.
1212
1313
This sketch is compatible with:
14-
- MKR 1000
15-
- MKR WiFi 1010
16-
- MKR GSM 1400
17-
- MKR NB 1500
18-
- MKR WAN 1300/1310
19-
- Nano 33 IoT
20-
- ESP8266
14+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
2115
*/
2216

2317
#include "arduino_secrets.h"

Diff for: examples/ArduinoIoTCloud-Basic/arduino_secrets.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

912
/* ESP8266 */
10-
#if defined(BOARD_ESP8266)
13+
#if defined(BOARD_ESP)
1114
#define SECRET_DEVICE_KEY "my-device-password"
1215
#endif
1316

Diff for: examples/ArduinoIoTCloud-Basic/thingProperties.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
#include <ArduinoIoTCloud.h>
2-
#include <Arduino_ConnectionHandler.h>
3-
41
#if defined(BOARD_HAS_WIFI)
52
#elif defined(BOARD_HAS_GSM)
63
#elif defined(BOARD_HAS_LORA)
74
#elif defined(BOARD_HAS_NB)
85
#else
9-
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
107
#endif
118

12-
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
9+
#if defined(BOARD_ESP)
10+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
11+
#endif
1312

1413
void onLedChange();
1514

@@ -18,7 +17,7 @@ int potentiometer;
1817
int seconds;
1918

2019
void initProperties() {
21-
#if defined(BOARD_ESP8266)
20+
#if defined(BOARD_ESP)
2221
ArduinoCloud.setBoardId(BOARD_ID);
2322
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2423
#endif

Diff for: examples/ArduinoIoTCloud-Callbacks/ArduinoIoTCloud-Callbacks.ino

+1-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@
2323
only after a value is sent to Cloud.
2424
2525
This sketch is compatible with:
26-
- MKR 1000
27-
- MKR WiFi 1010
28-
- MKR GSM 1400
29-
- MKR NB 1500
30-
- MKR WAN 1300/1310
31-
- Nano 33 IoT
32-
- ESP8266
26+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
3327
*/
3428

3529
#include "arduino_secrets.h"

Diff for: examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

9-
/* ESP8266 */
10-
#if defined(BOARD_ESP8266)
12+
/* ESP8266 ESP32*/
13+
#if defined(BOARD_ESP)
1114
#define SECRET_DEVICE_KEY "my-device-password"
1215
#endif
1316

Diff for: examples/ArduinoIoTCloud-Callbacks/thingProperties.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
#include <ArduinoIoTCloud.h>
2-
#include <Arduino_ConnectionHandler.h>
3-
41
#if defined(BOARD_HAS_WIFI)
52
#elif defined(BOARD_HAS_GSM)
63
#elif defined(BOARD_HAS_LORA)
74
#elif defined(BOARD_HAS_NB)
85
#else
9-
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
107
#endif
118

12-
/* BOARD_ID is only required if you are using an ESP8266 */
13-
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
9+
#if defined(BOARD_ESP)
10+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
11+
#endif
1412

1513
void initProperties() {
16-
#if defined(BOARD_ESP8266)
14+
#if defined(BOARD_ESP)
1715
ArduinoCloud.setBoardId(BOARD_ID);
1816
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1917
#endif

Diff for: examples/ArduinoIoTCloud-DeferredOTA/ArduinoIoTCloud-DeferredOTA.ino

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
* ask_user_via_serial callback will read user input from serial to apply or postpone OTA update
1111
1212
This sketch is compatible with:
13-
- MKR WiFi 1010
14-
- Nano 33 IoT
15-
- Portenta
16-
- Nano RP2040
13+
- https://github.com/arduino-libraries/ArduinoIoTCloud/#ota
1714
*/
1815

1916
#include "arduino_secrets.h"

Diff for: examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

9-
/* ESP8266 */
10-
#if defined(BOARD_ESP8266)
12+
/* ESP8266 ESP32*/
13+
#if defined(BOARD_ESP)
1114
#define SECRET_DEVICE_KEY "my-device-password"
1215
#endif
1316

Diff for: examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
#include <ArduinoIoTCloud.h>
2-
#include <Arduino_ConnectionHandler.h>
3-
41
#if defined(BOARD_HAS_WIFI)
52
#elif defined(BOARD_HAS_GSM)
63
#elif defined(BOARD_HAS_LORA)
74
#elif defined(BOARD_HAS_NB)
85
#else
9-
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
107
#endif
118

12-
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
9+
#if defined(BOARD_ESP)
10+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
11+
#endif
1312

1413
void onLedChange();
1514

1615
bool led;
1716

1817
void initProperties() {
19-
#if defined(BOARD_ESP8266)
18+
#if defined(BOARD_ESP)
2019
ArduinoCloud.setBoardId(BOARD_ID);
2120
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2221
#endif

Diff for: examples/ArduinoIoTCloud-Schedule/ArduinoIoTCloud-Schedule.ino

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
This sketch demonstrates how to use the cloud schedule variable type.
33
44
This sketch is compatible with the following boards:
5-
- MKR 1000
6-
- MKR WiFi 1010
7-
- MKR GSM 1400
8-
- MKR NB 1500
9-
- Nano 33 IoT
10-
- ESP8266
5+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
116
*/
127

138
#include "arduino_secrets.h"

Diff for: examples/ArduinoIoTCloud-Schedule/arduino_secrets.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

9-
/* ESP8266 */
10-
#if defined(BOARD_ESP8266)
12+
/* ESP8266 ESP32*/
13+
#if defined(BOARD_ESP)
1114
#define SECRET_DEVICE_KEY "my-device-password"
1215
#endif
1316

Diff for: examples/ArduinoIoTCloud-Schedule/thingProperties.h

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
#include <ArduinoIoTCloud.h>
2-
#include <Arduino_ConnectionHandler.h>
1+
#if defined(BOARD_HAS_WIFI)
2+
#elif defined(BOARD_HAS_GSM)
3+
#elif defined(BOARD_HAS_LORA)
4+
#elif defined(BOARD_HAS_NB)
5+
#else
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
7+
#endif
38

4-
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
9+
#if defined(BOARD_ESP)
10+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
11+
#endif
512

613
void onSwitchButtonChange();
714

@@ -15,7 +22,7 @@ CloudSchedule monthly;
1522
CloudSchedule yearly;
1623

1724
void initProperties() {
18-
#if defined(BOARD_ESP8266)
25+
#if defined(BOARD_ESP)
1926
ArduinoCloud.setBoardId(BOARD_ID);
2027
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2128
#endif

Diff for: examples/utility/ArduinoIoTCloud_Travis_CI/ArduinoIoTCloud_Travis_CI.ino

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
Arduino IoT Cloud API.
55
66
This sketch is compatible with:
7-
- MKR 1000
8-
- MKR WIFI 1010
9-
- MKR GSM 1400
10-
- MKR WAN 1300/1310
7+
- https://github.com/arduino-libraries/ArduinoIoTCloud#what
118
*/
129

1310
#include "arduino_secrets.h"

Diff for: examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
#include <ArduinoIoTCloud.h>
12
#include <Arduino_ConnectionHandler.h>
23

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

12+
/* ESP8266 ESP32*/
13+
#if defined(BOARD_ESP)
14+
#define SECRET_DEVICE_KEY "my-device-password"
15+
#endif
16+
917
/* MKR GSM 1400 */
1018
#if defined(BOARD_HAS_GSM)
1119
#define SECRET_PIN ""

Diff for: examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
/******************************************************************************
2-
INCLUDE
3-
******************************************************************************/
4-
5-
#include <ArduinoIoTCloud.h>
6-
#include <Arduino_ConnectionHandler.h>
7-
81
#if defined(BOARD_HAS_WIFI)
92
#elif defined(BOARD_HAS_GSM)
103
#elif defined(BOARD_HAS_LORA)
114
#elif defined(BOARD_HAS_NB)
125
#else
13-
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010, MKR WAN 1300/1310, MKR NB 1500 and MKR GSM 1400"
6+
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
7+
#endif
8+
9+
/******************************************************************************
10+
DEFINES
11+
******************************************************************************/
12+
13+
#if defined(BOARD_ESP)
14+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1415
#endif
1516

1617
/******************************************************************************
@@ -72,7 +73,10 @@ void onStringPropertyChange();
7273
******************************************************************************/
7374
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB)
7475
void initProperties() {
75-
76+
#if defined(BOARD_ESP)
77+
ArduinoCloud.setBoardId(BOARD_ID);
78+
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
79+
#endif
7680
ArduinoCloud.addProperty(bool_property_1, READWRITE, 1 * SECONDS);
7781
ArduinoCloud.addProperty(int_property_1, READ, 2 * MINUTES);
7882
ArduinoCloud.addProperty(float_property_1, WRITE, 3 * HOURS);

0 commit comments

Comments
 (0)