Skip to content

Commit 1eddd1b

Browse files
committed
Cleanup callback definition
1 parent 7e5fe28 commit 1eddd1b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/ArduinoIoTCloud.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ void ArduinoIoTCloudClass::poll()
206206
update();
207207
}
208208

209-
void ArduinoIoTCloudClass::update(void (*callback)(void))
209+
void ArduinoIoTCloudClass::update(CallbackFunc onSyncCompleteCallback)
210210
{
211211
// If user call update() without parameters use the default ones
212-
update(MAX_RETRIES, RECONNECTION_TIMEOUT, callback);
212+
update(MAX_RETRIES, RECONNECTION_TIMEOUT, onSyncCompleteCallback);
213213
}
214214

215215
void ArduinoIoTCloudClass::update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs)
@@ -237,8 +237,8 @@ void ArduinoIoTCloudClass::update(int const reconnectionMaxRetries, int const re
237237
}
238238
break;
239239
case SYNC_STATUS_VALUES_PROCESSED:
240-
if(callback != NULL)
241-
(*callback)();
240+
if(onSyncCompleteCallback != NULL)
241+
(*onSyncCompleteCallback)();
242242
syncStatus = SYNC_STATUS_SYNCHRONIZED;
243243
break;
244244
}

src/ArduinoIoTCloud.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ typedef struct {
4040
int timeout;
4141
} mqttConnectionOptions;
4242

43+
typedef void (*CallbackFunc)(void);
44+
4345
extern ConnectionManager *ArduinoIoTPreferredConnection;
4446

4547
enum ArduinoIoTConnectionStatus {
@@ -77,10 +79,10 @@ class ArduinoIoTCloudClass {
7779
bool disconnect();
7880

7981
void poll() __attribute__((deprecated)); /* Attention: Function is deprecated - use 'update' instead */
80-
void update(void (*callback)(void) = NULL);
82+
void update(CallbackFunc onSyncCompleteCallback = NULL);
8183

8284
// defined for users who want to specify max reconnections reties and timeout between them
83-
void update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs, void (*callback)(void) = NULL);
85+
void update(int const reconnectionMaxRetries, int const reconnectionTimeoutMs, CallbackFunc onSyncCompleteCallback = NULL);
8486

8587
int connected();
8688
// Clean up existing Mqtt connection, create a new one and initialize it

0 commit comments

Comments
 (0)