From 919c28a9c729cd09c85cede3e5a68681a2ac3b8e Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 23 Mar 2024 12:38:13 +0700 Subject: [PATCH] change SmartVariable Callback to std::function --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.cpp | 2 +- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.cpp index 1a81bc5..652bd84 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.cpp @@ -105,7 +105,7 @@ void SmartVariable::setValueAutoSave(bool autoSave) this->autoSave = autoSave; } -uint16_t SmartVariable::registerCallback(void (*callback)(char *)) +uint16_t SmartVariable::registerCallback(std::function callback) { this->valueChangeCallbacks[this->currentHandlerId] = callback; return this->currentHandlerId++; diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.hpp index 1550b50..77b7c78 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/SmartVariable.hpp @@ -23,7 +23,7 @@ public: void loadValue(); void saveValue(); void setValueAutoSave(bool autoSave); - uint16_t registerCallback(void (*callback)(char*)); + uint16_t registerCallback(std::function callback); void unregisterCallback(uint16_t handlerId); int32_t getIntValue(); void setIntValue(int32_t value); @@ -46,5 +46,5 @@ protected: void subscribeMqtt(); // Value Change Callback uint16_t currentHandlerId; - std::map valueChangeCallbacks; + std::map> valueChangeCallbacks; }; \ No newline at end of file