Skip to content

Commit d711115

Browse files
committed
Enable compilation of examples for both WiFi and GSM enab.ed boards
1 parent 074c4af commit d711115

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
If you prefer using a MKR GSM 1400 comment the lines above and uncommet the following.
1010
PIN, APN, Login and Password are supplied by your Cellular Data provider.
1111
*/
12-
//#define SECRET_PIN ""
13-
//#define SECRET_APN ""
14-
//#define SECRET_LOGIN ""
15-
//#define SECRET_PASS ""
12+
#define SECRET_PIN ""
13+
#define SECRET_APN ""
14+
#define SECRET_LOGIN ""
15+
#define SECRET_PASS ""
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include <ArduinoIoTCloud.h>
2-
/*
3-
The following include line is used for WiFi enabled boards (MKR1000, MKR WiFi 1010)
4-
*/
5-
#include <WiFiConnectionManager.h>
6-
/*
7-
If you prefer using a MKR GSM 1400 comment the line above and uncommet the following.
8-
*/
9-
//#include <GSMConnectionManager.h>
2+
#include <ConnectionManager.h>
3+
4+
#if defined(BOARD_HAS_WIFI)
5+
#include <WiFiConnectionManager.h>
6+
#elif defined(BOARD_HAS_GSM)
7+
#include <GSMConnectionManager.h>
8+
#else
9+
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
10+
#endif
11+
1012

1113
// Your THING_ID
1214
#define THING_ID "ARDUINO_IOT_CLOUD_THING_ID"
@@ -22,11 +24,10 @@ void initProperties() {
2224
ArduinoCloud.addProperty(potentiometer, READ, ON_CHANGE);
2325
}
2426

25-
/*
26-
The following include line is used for WiFi enabled boards (MKR1000, MKR WiFi 1010)
27-
*/
28-
ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
29-
/*
30-
If you prefer using a MKR GSM 1400 comment the line above and uncommet the following.
31-
*/
32-
//ConnectionManager *ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
27+
#if defined(BOARD_HAS_WIFI)
28+
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
29+
#elif defined(BOARD_HAS_GSM)
30+
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager (SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
31+
#endif
32+
33+

0 commit comments

Comments
 (0)