Skip to content

Commit fb8f194

Browse files
committed
first draft of properties synchronization using individual callback
1 parent 9417c06 commit fb8f194

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/ArduinoIoTCloud.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ class ArduinoIoTCloudClass {
7272
bool disconnect();
7373

7474
void poll() __attribute__((deprecated)); /* Attention: Function is deprecated - use 'update' instead */
75-
void update(int mode = PROPERTIES_SYNC_FORCE_DEVICE, void (*callback)(void) = NULL);
75+
void update(void (*callback)(void) = NULL);
7676

7777
// defined for users who want to specify max reconnections reties and timeout between them
78-
void update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs, int mode = PROPERTIES_SYNC_FORCE_DEVICE, void (*callback)(void) = NULL);
78+
void update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs, void (*callback)(void) = NULL);
7979
// get the status of synchronization after getLastValues request
8080
bool getLastValuesSyncStatus();
8181

@@ -95,17 +95,17 @@ class ArduinoIoTCloudClass {
9595

9696

9797
template<typename T, typename N=T>
98-
void addPropertyReal(T & property, String name, permissionType permission_type = READWRITE, long seconds = ON_CHANGE, void(*fn)(void) = NULL, N minDelta = N(0)) {
98+
void addPropertyReal(T & property, String name, permissionType permission_type = READWRITE, int syncMode = PROPERTIES_SYNC_FORCE_DEVICE, void(*synFn)(ArduinoCloudProperty<T> property) = NULL, long seconds = ON_CHANGE, void(*fn)(void) = NULL, N minDelta = N(0)) {
9999
Permission permission = Permission::ReadWrite;
100100
if (permission_type == READ ) permission = Permission::Read;
101101
else if(permission_type == WRITE) permission = Permission::Write;
102102
else permission = Permission::ReadWrite;
103103

104104
if(seconds == ON_CHANGE) {
105-
Thing.addPropertyReal(property, name, permission).publishOnChange((T)minDelta, DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn);
105+
Thing.addPropertyReal(property, name, permission, syncMode).publishOnChange((T)minDelta, DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
106106
}
107107
else {
108-
Thing.addPropertyReal(property, name, permission).publishEvery(seconds).onUpdate(fn);
108+
Thing.addPropertyReal(property, name, permission, syncMode).publishEvery(seconds).onUpdate(fn).onSync(synFn);
109109
}
110110
}
111111

@@ -129,8 +129,8 @@ class ArduinoIoTCloudClass {
129129
void mqttClientBegin();
130130
// Function in charge of perform MQTT reconnection, basing on class parameters(retries,and timeout)
131131
bool mqttReconnect(int const maxRetries, int const timeout);
132-
// Used to retrieve ast values from _shadowTopicIn
133-
void getLastValues();
132+
// Used to retrieve last values from _shadowTopicIn
133+
void requestLastValue();
134134

135135
ArduinoIoTConnectionStatus getIoTStatus() { return iotStatus; }
136136
void setIoTConnectionState(ArduinoIoTConnectionStatus _newState);
@@ -147,8 +147,7 @@ class ArduinoIoTCloudClass {
147147
ArduinoCloudThing Thing;
148148
BearSSLClient* _bearSslClient;
149149
MqttClient* _mqttClient;
150-
int _mode,
151-
_lastSyncRequestTickTime;
150+
int _lastSyncRequestTickTime;
152151
bool _callGetLastValueCallback;
153152

154153

0 commit comments

Comments
 (0)