Skip to content

Commit bc6e0cd

Browse files
authored
Merge pull request #362 from pennam/esp_to_secret
Configuration: Add BOARD_HAS_SECRET_KEY
2 parents 7b62b65 + 19bce50 commit bc6e0cd

File tree

15 files changed

+26
-22
lines changed

15 files changed

+26
-22
lines changed

examples/ArduinoIoTCloud-Advanced/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/ArduinoIoTCloud-Advanced/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
99

10-
#if defined(BOARD_ESP)
10+
#if defined(BOARD_HAS_SECRET_KEY)
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

@@ -19,7 +19,7 @@ CloudLocation location;
1919
CloudColor color;
2020

2121
void initProperties() {
22-
#if defined(BOARD_ESP)
22+
#if defined(BOARD_HAS_SECRET_KEY)
2323
ArduinoCloud.setBoardId(BOARD_ID);
2424
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2525
#endif

examples/ArduinoIoTCloud-Basic/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/ArduinoIoTCloud-Basic/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
99

10-
#if defined(BOARD_ESP)
10+
#if defined(BOARD_HAS_SECRET_KEY)
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

@@ -18,7 +18,7 @@ int potentiometer;
1818
int seconds;
1919

2020
void initProperties() {
21-
#if defined(BOARD_ESP)
21+
#if defined(BOARD_HAS_SECRET_KEY)
2222
ArduinoCloud.setBoardId(BOARD_ID);
2323
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2424
#endif

examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/ArduinoIoTCloud-Callbacks/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
99

10-
#if defined(BOARD_ESP)
10+
#if defined(BOARD_HAS_SECRET_KEY)
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

1414
void initProperties() {
15-
#if defined(BOARD_ESP)
15+
#if defined(BOARD_HAS_SECRET_KEY)
1616
ArduinoCloud.setBoardId(BOARD_ID);
1717
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
1818
#endif

examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
99

10-
#if defined(BOARD_ESP)
10+
#if defined(BOARD_HAS_SECRET_KEY)
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

@@ -16,7 +16,7 @@ void onLedChange();
1616
bool led;
1717

1818
void initProperties() {
19-
#if defined(BOARD_ESP)
19+
#if defined(BOARD_HAS_SECRET_KEY)
2020
ArduinoCloud.setBoardId(BOARD_ID);
2121
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2222
#endif

examples/ArduinoIoTCloud-Schedule/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/ArduinoIoTCloud-Schedule/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
88
#endif
99

10-
#if defined(BOARD_ESP)
10+
#if defined(BOARD_HAS_SECRET_KEY)
1111
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1212
#endif
1313

@@ -23,7 +23,7 @@ CloudSchedule monthly;
2323
CloudSchedule yearly;
2424

2525
void initProperties() {
26-
#if defined(BOARD_ESP)
26+
#if defined(BOARD_HAS_SECRET_KEY)
2727
ArduinoCloud.setBoardId(BOARD_ID);
2828
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
2929
#endif

examples/utility/ArduinoIoTCloud_Travis_CI/arduino_secrets.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#endif
1111

1212
/* ESP8266 ESP32*/
13-
#if defined(BOARD_ESP)
13+
#if defined(BOARD_HAS_SECRET_KEY)
1414
#define SECRET_DEVICE_KEY "my-device-password"
1515
#endif
1616

examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
DEFINES
1212
******************************************************************************/
1313

14-
#if defined(BOARD_ESP)
14+
#if defined(BOARD_HAS_SECRET_KEY)
1515
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
1616
#endif
1717

@@ -79,7 +79,7 @@ void onStringPropertyChange();
7979
******************************************************************************/
8080
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB)
8181
void initProperties() {
82-
#if defined(BOARD_ESP)
82+
#if defined(BOARD_HAS_SECRET_KEY)
8383
ArduinoCloud.setBoardId(BOARD_ID);
8484
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
8585
#endif

src/AIoTC_Config.h

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143

144144
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
145145
#define BOARD_ESP
146+
#define BOARD_HAS_SECRET_KEY
146147
#define HAS_TCP
147148
#endif
148149

src/ArduinoIoTCloudTCP.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
8686
#ifdef BOARD_HAS_ECCX08
8787
, _sslClient(nullptr, ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM, getTime)
8888
#endif
89-
#ifdef BOARD_ESP
89+
#ifdef BOARD_HAS_SECRET_KEY
9090
, _password("")
9191
#endif
9292
, _mqttClient{nullptr}
@@ -176,7 +176,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
176176
#endif
177177

178178
_mqttClient.setClient(_sslClient);
179-
#ifdef BOARD_ESP
179+
#ifdef BOARD_HAS_SECRET_KEY
180180
_mqttClient.setUsernamePassword(getDeviceId(), _password);
181181
#endif
182182
_mqttClient.onMessage(ArduinoIoTCloudTCP::onMessage);

src/ArduinoIoTCloudTCP.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
8484
#endif
8585
int begin(bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS_SECURE_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_SECURE_AUTH);
8686

87-
#ifdef BOARD_ESP
87+
#ifdef BOARD_HAS_SECRET_KEY
8888
inline void setBoardId (String const device_id) { setDeviceId(device_id); }
8989
inline void setSecretDeviceKey(String const password) { _password = password; }
9090
#endif
@@ -148,7 +148,6 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
148148
CryptoUtil _crypto;
149149
#elif defined(BOARD_ESP)
150150
WiFiClientSecure _sslClient;
151-
String _password;
152151
#elif defined(ARDUINO_PORTENTA_C33)
153152
ArduinoIoTCloudCertClass _cert;
154153
SSLClient _sslClient;
@@ -159,6 +158,10 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
159158
CryptoUtil _crypto;
160159
#endif
161160

161+
#if defined (BOARD_HAS_SECRET_KEY)
162+
String _password;
163+
#endif
164+
162165
MqttClient _mqttClient;
163166

164167
String _deviceTopicOut;

0 commit comments

Comments
 (0)