From b81989a2cddaa6387cb21204634b916dd1f6de86 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Sun, 24 Sep 2023 00:23:16 +0530 Subject: [PATCH] - Improved callbacks --- src/ElegantOTA.cpp | 6 +++--- src/ElegantOTA.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ElegantOTA.cpp b/src/ElegantOTA.cpp index bf70f0a..4bf7bfa 100644 --- a/src/ElegantOTA.cpp +++ b/src/ElegantOTA.cpp @@ -332,15 +332,15 @@ void ElegantOTAClass::loop() { } } -void ElegantOTAClass::onStart(void callable(void)){ +void ElegantOTAClass::onStart(std::function callable){ preUpdateCallback = callable; } -void ElegantOTAClass::onProgress(void callable(size_t current, size_t final)){ +void ElegantOTAClass::onProgress(std::function callable){ progressUpdateCallback= callable; } -void ElegantOTAClass::onEnd(void callable(bool success)){ +void ElegantOTAClass::onEnd(std::function callable){ postUpdateCallback = callable; } diff --git a/src/ElegantOTA.h b/src/ElegantOTA.h index d13962a..57af515 100644 --- a/src/ElegantOTA.h +++ b/src/ElegantOTA.h @@ -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 callable); + void onProgress(std::function callable); + void onEnd(std::function callable); private: ELEGANTOTA_WEBSERVER *_server; @@ -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 preUpdateCallback = NULL; + std::function progressUpdateCallback = NULL; + std::function postUpdateCallback = NULL; }; extern ElegantOTAClass ElegantOTA;