Closed tripflex closed 6 years ago
I haven't tried, but you could use a lambda function for this, e.g. something like this:
advertise("on").settable([this](const HomieRange& range, const String& value) {this->handleOn(range,value);});
confirmed
something like this should work (compiles)
http://en.cppreference.com/w/cpp/language/lambda
[this](const HomieRange& range, const String& value) -> bool{ return true; }
capturing this ([this]
) means you can use this: this->function()
also looks like you class names are inconsistent ?
CustomNode::CustomNode
MisterNode::handleOn
@euphi awesome thank you will try this right now and let you know!
@timpur thanks for the reply, yeah I was just trying to clean it up and make the code as simple as possible, the node is really named MisterNode
I just forgot to change that one as well, thanks for pointing it out though and both of your help
@tripflex I forgot the return value (Thats the -> bool
part in @timpur 's explanation).
So it should look like
advertise("on").settable([this](const HomieRange& range, const String& value) -> bool {return this->handleOn(range,value);});
@tripflex please close if all is working, thanks.
Awesome, thanks for all the help @euphi and @timpur
Forgive me for my C++ knowledge is fairly limited, but spent the past 3-4 hours trying to figure this out with no results ... i've basically created a custom node class and wanted to be able to handle setting the properties from inside the same class, but am unable to do so.
Here's what I was trying to do:
Now I can do this using the Node handler, but I was trying to separate each property (as there are a few of them), into separate methods to handle each one
http://marvinroger.github.io/homie-esp8266/docs/2.0.0-beta.2/advanced-usage/input-handlers/
Can someone please help me with this? I don't think i'll have any hair left by the end of the day if I can't figure something out. Thank you!!!