change SmartVariable Callback to std::function

This commit is contained in:
Siwat Sirichai 2024-03-23 12:38:13 +07:00
parent 1d977c5bdf
commit 919c28a9c7
2 changed files with 3 additions and 3 deletions

View File

@ -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<void(char *)> callback)
{
this->valueChangeCallbacks[this->currentHandlerId] = callback;
return this->currentHandlerId++;

View File

@ -23,7 +23,7 @@ public:
void loadValue();
void saveValue();
void setValueAutoSave(bool autoSave);
uint16_t registerCallback(void (*callback)(char*));
uint16_t registerCallback(std::function<void(char*)> 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<uint16_t, void (*)(char*)> valueChangeCallbacks;
std::map<uint16_t, std::function<void(char*)>> valueChangeCallbacks;
};