Skip to content

Commit 2a499cf

Browse files
committed
Adding 'seconds' property to examples and change addProperty call for non-lora boards to showcase the seconds possible way of constructing properties
1 parent 48c8661 commit 2a499cf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

examples/ArduinoIoTCloud_LED_switch/ArduinoIoTCloud_LED_switch.ino

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void setup() {
4343
void loop() {
4444
ArduinoCloud.update();
4545
potentiometer = analogRead(A0);
46+
seconds = millis() / 1000;
4647
}
4748

4849
/*

examples/ArduinoIoTCloud_LED_switch/thingProperties.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void onLedChange();
1616

1717
bool led;
1818
int potentiometer;
19+
int seconds;
1920

2021
void initProperties() {
2122
#if defined(BOARD_ESP8266)
@@ -24,11 +25,13 @@ void initProperties() {
2425
#endif
2526
ArduinoCloud.setThingId(THING_ID);
2627
#if defined(BOARD_HAS_WIFI) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_NB)
27-
ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);
28-
ArduinoCloud.addProperty(potentiometer, READ, ON_CHANGE);
28+
ArduinoCloud.addProperty(led, Permission::Write).onUpdate(onLedChange);
29+
ArduinoCloud.addProperty(potentiometer, Permission::Read).publishOnChange(10);
30+
ArduinoCloud.addProperty(seconds, Permission::Read).publishOnChange(1);
2931
#elif defined(BOARD_HAS_LORA)
3032
ArduinoCloud.addProperty(led, 1, READWRITE, ON_CHANGE, onLedChange);
3133
ArduinoCloud.addProperty(potentiometer, 2, READ, ON_CHANGE);
34+
ArduinoCloud.addProperty(seconds, 3, READ, 5 * MINUTES);
3235
#endif
3336
}
3437

0 commit comments

Comments
 (0)