Hi,
I want this:
MyClass::begin(){ Particle.function("myfunction",doIt); } int MyClass::doIt(String str){}
I tried:
1. Particle.function("myfunction",MyClass::doIt); 2. Particle.function("myfunction",this->doIt);
Is it is possible at all, and if, how
Compared to a regular function pointer (which is a single pointer) a class function is actually 2 pointers - the function itself and the βthisβ pointer. The simplest way to encapsulate both of these so to use a lambda expression.
class MyClass { void begin() { Particle.function("myfunc", [this](const String& s)->int{return doIt(s); }); } int doIt(String arg) { return 0; } };
Perfect, works, tnx