Skip to content

Commit aacce67

Browse files
committed
Extend multi value example to be compilable for all supported boards
1 parent 6f7c5dd commit aacce67

File tree

3 files changed

+58
-11
lines changed

3 files changed

+58
-11
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ script:
9090
[ "$BOARD" == "arduino:samd:mkrwan1300" ]; then
9191
buildSketch \
9292
"ArduinoIoTCloud-Basic" \
93+
"MultiValue_example" \
9394
"utility/ArduinoIoTCloud_Travis_CI"
9495
fi
9596
# Sketches to build for selected boards
9697
- |
9798
if [ "$BOARD" == "arduino:samd:mkr1000" ] || [ "$BOARD" == "arduino:samd:mkrwifi1010" ] || [ "$BOARD" == "arduino:samd:nano_33_iot"]; then
9899
buildSketch \
99100
"utility/Provisioning" \
100-
"utility/WiFi_Cloud_Blink" \
101-
"MultiValue_example"
101+
"utility/WiFi_Cloud_Blink"
102102
fi
103103
- |
104104
if [ "$BOARD" == "arduino:samd:mkrgsm1400" ]; then
+34-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,34 @@
1-
#define SECRET_SSID ""
2-
#define SECRET_PASS ""
1+
#include <Arduino_ConnectionHandler.h>
2+
3+
/* MKR1000, MKR WiFi 1010 */
4+
#if defined(BOARD_HAS_WIFI)
5+
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
6+
#define SECRET_PASS "YOUR_WIFI_PASSWORD"
7+
#endif
8+
9+
/* ESP8266 */
10+
#if defined(BOARD_ESP8266)
11+
#define SECRET_DEVICE_KEY "my-device-password"
12+
#endif
13+
14+
/* MKR GSM 1400 */
15+
#if defined(BOARD_HAS_GSM)
16+
#define SECRET_PIN ""
17+
#define SECRET_APN ""
18+
#define SECRET_LOGIN ""
19+
#define SECRET_PASS ""
20+
#endif
21+
22+
/* MKR WAN 1300/1310 */
23+
#if defined(BOARD_HAS_LORA)
24+
#define SECRET_APP_EUI ""
25+
#define SECRET_APP_KEY ""
26+
#endif
27+
28+
/* MKR NB 1500 */
29+
#if defined(BOARD_HAS_NB)
30+
#define SECRET_PIN ""
31+
#define SECRET_APN ""
32+
#define SECRET_LOGIN ""
33+
#define SECRET_PASS ""
34+
#endif
+22-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#include <ArduinoIoTCloud.h>
22
#include <Arduino_ConnectionHandler.h>
33

4-
// Set the Thing Id value
5-
const char THING_ID[] = "";
6-
7-
const char SSID[] = SECRET_SSID; // Network SSID (name)
8-
const char PASS[] = SECRET_PASS; // Network password (use for WPA, or use as key for WEP)
4+
#define THING_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
5+
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
96

107
void onSwitchButtonChange();
118
void onColorChange();
@@ -15,10 +12,28 @@ CloudLocation location;
1512
CloudColor color;
1613

1714
void initProperties() {
15+
#if defined(BOARD_ESP8266)
16+
ArduinoCloud.setBoardId(BOARD_ID);
17+
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
18+
#endif
1819
ArduinoCloud.setThingId(THING_ID);
20+
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
1921
ArduinoCloud.addProperty(switchButton, READWRITE, ON_CHANGE, onSwitchButtonChange);
20-
ArduinoCloud.addProperty(location, READ, ON_CHANGE, NULL);
22+
ArduinoCloud.addProperty(location, READ, ON_CHANGE);
2123
ArduinoCloud.addProperty(color, READWRITE, ON_CHANGE, onColorChange);
24+
#elif defined(BOARD_HAS_LORA)
25+
ArduinoCloud.addProperty(switchButton, 1, READWRITE, ON_CHANGE, onSwitchButtonChange);
26+
ArduinoCloud.addProperty(location, 2, READ, ON_CHANGE);
27+
ArduinoCloud.addProperty(color, 3, READWRITE, ON_CHANGE, onColorChange);
28+
#endif
2229
}
2330

24-
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
31+
#if defined(BOARD_HAS_WIFI)
32+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
33+
#elif defined(BOARD_HAS_GSM)
34+
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
35+
#elif defined(BOARD_HAS_LORA)
36+
LoRaConnectionHandler ArduinoIoTPreferredConnection(SECRET_APP_EUI, SECRET_APP_KEY, _lora_band::EU868, _lora_class::CLASS_A);
37+
#elif defined(BOARD_HAS_NB)
38+
NBConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
39+
#endif

0 commit comments

Comments
 (0)