remote var callback docs
This commit is contained in:
parent
57dfa30cf0
commit
1dd0862834
|
@ -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<void(char*)> 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);
|
||||
}
|
Loading…
Reference in New Issue