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 2 commits
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
1 change: 1 addition & 0 deletions src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@

#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
4 changes: 2 additions & 2 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 @@ -173,7 +173,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
#endif

_mqttClient.setClient(_sslClient);
#ifdef BOARD_ESP
#ifdef BOARD_HAS_SECRET_KEY
_mqttClient.setUsernamePassword(getDeviceId(), _password);
#endif
_mqttClient.onMessage(ArduinoIoTCloudTCP::onMessage);
Expand Down
7 changes: 5 additions & 2 deletions src/ArduinoIoTCloudTCP.h
Original file line number Diff line number Diff line change
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 @@ -145,13 +145,16 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
CryptoUtil _crypto;
#elif defined(BOARD_ESP)
WiFiClientSecure _sslClient;
String _password;
#elif defined(BOARD_HAS_SE050)
ArduinoIoTCloudCertClass _cert;
WiFiSSLSE050Client _sslClient;
CryptoUtil _crypto;
#endif

#if defined (BOARD_HAS_SECRET_KEY)
String _password;
#endif

MqttClient _mqttClient;

String _deviceTopicOut;
Expand Down