Skip to content

Configuration: Add BOARD_HAS_SECRET_KEY #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Advanced/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/ArduinoIoTCloud-Advanced/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand All @@ -19,7 +19,7 @@ CloudLocation location;
CloudColor color;

void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Basic/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/ArduinoIoTCloud-Basic/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand All @@ -18,7 +18,7 @@ int potentiometer;
int seconds;

void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Callbacks/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/ArduinoIoTCloud-Callbacks/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-DeferredOTA/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/ArduinoIoTCloud-DeferredOTA/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand All @@ -16,7 +16,7 @@ void onLedChange();
bool led;

void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-Schedule/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/ArduinoIoTCloud-Schedule/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#error "Please check Arduino IoT Cloud supported boards list: https://github.com/arduino-libraries/ArduinoIoTCloud/#what"
#endif

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand All @@ -23,7 +23,7 @@ CloudSchedule monthly;
CloudSchedule yearly;

void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define SECRET_DEVICE_KEY "my-device-password"
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/utility/ArduinoIoTCloud_Travis_CI/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
DEFINES
******************************************************************************/

#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
#define BOARD_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
#endif

Expand Down Expand Up @@ -79,7 +79,7 @@ void onStringPropertyChange();
******************************************************************************/
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined (BOARD_HAS_NB)
void initProperties() {
#if defined(BOARD_ESP)
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
#endif

#if defined(ARDUINO_ESP8266_ESP12) || defined(ARDUINO_ARCH_ESP32) || defined(ESP8266) || defined(ESP32)
#define BOARD_ESP
#define BOARD_HAS_SECRET_KEY
#define HAS_TCP
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
#ifdef BOARD_HAS_ECCX08
, _sslClient(nullptr, ArduinoIoTCloudTrustAnchor, ArduinoIoTCloudTrustAnchor_NUM, getTime)
#endif
#ifdef BOARD_ESP
#ifdef BOARD_HAS_SECRET_KEY
, _password("")
#endif
, _mqttClient{nullptr}
Expand Down Expand Up @@ -168,12 +168,12 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
_sslClient.setClient(_connection->getClient());
#elif defined(BOARD_HAS_SE050)
_sslClient.appendCustomCACert(AIoTSSCert);
#elif defined(BOARD_ESP)
#elif defined(BOARD_HAS_SECRET_KEY)
_sslClient.setInsecure();
#endif

_mqttClient.setClient(_sslClient);
#ifdef BOARD_ESP
#ifdef BOARD_HAS_SECRET_KEY
_mqttClient.setUsernamePassword(getDeviceId(), _password);
#endif
_mqttClient.onMessage(ArduinoIoTCloudTCP::onMessage);
Expand Down
6 changes: 3 additions & 3 deletions src/ArduinoIoTCloudTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifdef BOARD_HAS_ECCX08
#include "tls/BearSSLClient.h"
#include "tls/utility/CryptoUtil.h"
#elif defined(BOARD_ESP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one and the following one using WiFiClientSecure should stay under BOARD_ESP (which, by itself, should define BOARD_HAS_SECRET_KEY)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, i was thinking to do it when adding the other boards, but better to do it now!

#elif defined(BOARD_HAS_SECRET_KEY)
#include <WiFiClientSecure.h>
#elif defined(BOARD_HAS_SE050)
#include "tls/utility/CryptoUtil.h"
Expand Down Expand Up @@ -81,7 +81,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
#endif
int begin(bool const enable_watchdog = true, String brokerAddress = DEFAULT_BROKER_ADDRESS_SECURE_AUTH, uint16_t brokerPort = DEFAULT_BROKER_PORT_SECURE_AUTH);

#ifdef BOARD_ESP
#ifdef BOARD_HAS_SECRET_KEY
inline void setBoardId (String const device_id) { setDeviceId(device_id); }
inline void setSecretDeviceKey(String const password) { _password = password; }
#endif
Expand Down Expand Up @@ -143,7 +143,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
ArduinoIoTCloudCertClass _cert;
WiFiBearSSLClient _sslClient;
CryptoUtil _crypto;
#elif defined(BOARD_ESP)
#elif defined(BOARD_HAS_SECRET_KEY)
WiFiClientSecure _sslClient;
String _password;
#elif defined(BOARD_HAS_SE050)
Expand Down