Skip to content

Commit 2fddfc4

Browse files
aentingermattiabertorello
authored andcommitted
Restoring previous macro for automatically generating property string name out of property variable name
1 parent 6b5429d commit 2fddfc4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

examples/MKR1000_Cloud_Blink/MKR1000_Cloud_Blink.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void setup() {
8080

8181
Serial.println("Successfully connected to Arduino Cloud :)");
8282

83-
ArduinoCloud.addProperty(position, "position", READ, 10*SECONDS, onPositionUpdate);
83+
ArduinoCloud.addProperty(position, READ, 10*SECONDS, onPositionUpdate);
8484

8585
CloudSerial.begin(9600);
8686
CloudSerial.print("I'm ready for blinking!\n");

src/ArduinoIoTCloud.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,26 @@ class ArduinoIoTCloudClass {
5050
// Clean up existing Mqtt connection, create a new one and initialize it
5151
int reconnect(Client& net);
5252

53+
#define addProperty( v, ...) addPropertyReal(v, #v, __VA_ARGS__)
54+
5355
template<typename T, typename N=T>
54-
void addProperty(T & property, String name, permissionType permission_type = READWRITE, long seconds = ON_CHANGE, void(*fn)(void) = NULL, N minDelta = N(0)) {
56+
void addPropertyReal(T & property, String name, permissionType permission_type = READWRITE, long seconds = ON_CHANGE, void(*fn)(void) = NULL, N minDelta = N(0)) {
5557
Permission permission = Permission::ReadWrite;
5658
if (permission_type == READ ) permission = Permission::Read;
5759
else if(permission_type == WRITE) permission = Permission::Write;
5860
else permission = Permission::ReadWrite;
5961

6062
if(seconds == ON_CHANGE) {
61-
Thing.addProperty(property, name, permission).publishOnChange((T)minDelta).onUpdate(fn);
63+
Thing.addPropertyReal(property, name, permission).publishOnChange((T)minDelta).onUpdate(fn);
6264
}
6365
else {
64-
Thing.addProperty(property, name, permission).publishEvery(seconds).onUpdate(fn);
66+
Thing.addPropertyReal(property, name, permission).publishEvery(seconds).onUpdate(fn);
6567
}
6668
}
6769

6870
template <typename T>
69-
ArduinoCloudProperty<T> addProperty(T & property, String const & name, Permission const permission) {
70-
return Thing.addProperty(property, name, permission);
71+
ArduinoCloudProperty<T> addPropertyReal(T & property, String const & name, Permission const permission) {
72+
return Thing.addPropertyReal(property, name, permission);
7173
}
7274

7375
protected:

0 commit comments

Comments
 (0)