1
1
#include <ArduinoIoTCloud.h>
2
2
#include <Arduino_ConnectionHandler.h>
3
3
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"
9
6
10
7
void onSwitchButtonChange ();
11
8
void onColorChange ();
@@ -15,10 +12,28 @@ CloudLocation location;
15
12
CloudColor color ;
16
13
17
14
void initProperties () {
15
+ #if defined(BOARD_ESP8266 )
16
+ ArduinoCloud .setBoardId (BOARD_ID );
17
+ ArduinoCloud .setSecretDeviceKey (SECRET_DEVICE_KEY );
18
+ #endif
18
19
ArduinoCloud .setThingId (THING_ID );
20
+ #if defined(BOARD_HAS_WIFI ) || defined(BOARD_HAS_GSM ) || defined(BOARD_HAS_NB )
19
21
ArduinoCloud .addProperty (switchButton , READWRITE , ON_CHANGE , onSwitchButtonChange );
20
- ArduinoCloud .addProperty (location , READ , ON_CHANGE , NULL );
22
+ ArduinoCloud .addProperty (location , READ , ON_CHANGE );
21
23
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
22
29
}
23
30
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