From 1dd08628344e98b93eab94f8e3f2aa923c97792b Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 13 Feb 2024 01:00:20 +0700 Subject: [PATCH] remote var callback docs --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/RemoteVariable.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/RemoteVariable.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/RemoteVariable.cpp index e06b622..53eef01 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/RemoteVariable.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/RemoteVariable.cpp @@ -135,10 +135,22 @@ void RemoteVariable::setValue(const char* value) { this->iot->publish(this->setValueTopic, value); } +/** + * @brief Register a callback for value change + * This method will be called when the value of the variable changes on the remote device + * @param callback The callback function + * @return uint8_t The handler for the callback +*/ uint8_t RemoteVariable::registerCallback(std::function callback) { this->valueChangeCallback[this->valueChangeCallbackCount] = callback; return valueChangeCallbackCount++; } + +/** + * @brief Unregister a callback + * This method is used to unregister a callback + * @param handler The handler of the callback +*/ void RemoteVariable::unregisterCallback(uint8_t handler) { this->valueChangeCallback.erase(handler); } \ No newline at end of file