Skip to content

Commit

Permalink
- Improved callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushsharma82 committed Sep 23, 2023
1 parent c08acad commit b81989a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/ElegantOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ void ElegantOTAClass::loop() {
}
}

void ElegantOTAClass::onStart(void callable(void)){
void ElegantOTAClass::onStart(std::function<void()> callable){
preUpdateCallback = callable;
}

void ElegantOTAClass::onProgress(void callable(size_t current, size_t final)){
void ElegantOTAClass::onProgress(std::function<void(size_t current, size_t final)> callable){
progressUpdateCallback= callable;
}

void ElegantOTAClass::onEnd(void callable(bool success)){
void ElegantOTAClass::onEnd(std::function<void(bool success)> callable){
postUpdateCallback = callable;
}

Expand Down
12 changes: 6 additions & 6 deletions src/ElegantOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ class ElegantOTAClass{
void setAutoReboot(bool enable);
void loop();

void onStart(void callable(void));
void onProgress(void callable(size_t current, size_t final));
void onEnd(void callable(bool success));
void onStart(std::function<void()> callable);
void onProgress(std::function<void(size_t current, size_t final)> callable);
void onEnd(std::function<void(bool success)> callable);

private:
ELEGANTOTA_WEBSERVER *_server;
Expand All @@ -126,9 +126,9 @@ class ElegantOTAClass{
String _update_error_str = "";
unsigned long _current_progress_size;

void (*preUpdateCallback)() = NULL;
void (*progressUpdateCallback)(size_t current, size_t final) = NULL;
void (*postUpdateCallback)(bool success) = NULL;
std::function<void()> preUpdateCallback = NULL;
std::function<void(size_t current, size_t final)> progressUpdateCallback = NULL;
std::function<void(bool success)> postUpdateCallback = NULL;
};

extern ElegantOTAClass ElegantOTA;
Expand Down

0 comments on commit b81989a

Please sign in to comment.