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
107void onSwitchButtonChange ();
118void onColorChange ();
@@ -15,10 +12,28 @@ CloudLocation location;
1512CloudColor color ;
1613
1714void 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