Skip to content

examples: fix username/password secure element logic #530

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 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -22,14 +22,15 @@ CloudLocation location;
CloudColor color;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(HAS_TCP)
ArduinoCloud.addProperty(switchButton, Permission::Write).onUpdate(onSwitchButtonChange);
ArduinoCloud.addProperty(location, Permission::Read).publishOnChange(0.0f);
ArduinoCloud.addProperty(color, Permission::ReadWrite).onUpdate(onColorChange);

#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(switchButton, 1, Permission::Write).onUpdate(onSwitchButtonChange);
ArduinoCloud.addProperty(location, 2, Permission::Read).publishOnChange(0.0f);
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 @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -21,14 +21,15 @@ int potentiometer;
int seconds;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(HAS_TCP)
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);

#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
Expand Down
2 changes: 1 addition & 1 deletion examples/ArduinoIoTCloud-BlockForOTA/arduino_secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -21,14 +21,15 @@ int potentiometer;
int seconds;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(HAS_TCP)
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);

#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(led, 1, Permission::ReadWrite).onUpdate(onLedChange);
ArduinoCloud.addProperty(potentiometer, 2, Permission::Read).publishOnChange(10);
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 @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -15,11 +15,12 @@
#endif

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
#if defined(HAS_TCP)
#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(BOARD_HAS_LORA)
#elif defined(HAS_LORA)
ArduinoCloud.setThingId(THING_ID);
#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 @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -15,11 +15,12 @@ void onLedChange();
bool led;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
#if defined(HAS_TCP)
#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif

#endif
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
}

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 @@ -9,7 +9,7 @@
#endif

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

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

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

Expand All @@ -26,10 +26,6 @@ CloudSchedule monthly;
CloudSchedule yearly;

void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#if defined(HAS_TCP)
ArduinoCloud.addProperty(switchButton, Permission::Write);
ArduinoCloud.addProperty(oneShot, Permission::ReadWrite);
Expand All @@ -39,6 +35,11 @@ void initProperties() {
ArduinoCloud.addProperty(weekly, Permission::ReadWrite);
ArduinoCloud.addProperty(monthly, Permission::ReadWrite);
ArduinoCloud.addProperty(yearly, Permission::ReadWrite);

#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
#elif defined(HAS_LORA)
ArduinoCloud.addProperty(switchButton, 1, Permission::Write);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif

/* ESP8266 ESP32*/
#if defined(BOARD_HAS_SECRET_KEY)
#if !defined(BOARD_HAS_SECURE_ELEMENT)
#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 @@ -10,7 +10,7 @@
DEFINES
******************************************************************************/

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

Expand Down Expand Up @@ -86,7 +86,7 @@ void onStringPropertyChange();
******************************************************************************/
#if defined(HAS_TCP)
void initProperties() {
#if defined(BOARD_HAS_SECRET_KEY)
#if !defined(BOARD_HAS_SECURE_ELEMENT)
ArduinoCloud.setBoardId(BOARD_ID);
ArduinoCloud.setSecretDeviceKey(SECRET_DEVICE_KEY);
#endif
Expand Down