0

Hello i try connect the method to parameter TaskCallback of class Task. I don't know how to do this. Could you help me?

typedef std::function<void ()> TaskCallback

class Task {
Task(unsigned long aInterval=0, long aIterations=0, TaskCallback aCallback=NULL, Scheduler* aScheduler=NULL, bool aEnable=false, TaskOnEnable aOnEnable=NULL, TaskOnDisable aOnDisable=NULL
}

class Mesh_PDP : public painlessMesh
}

{
public:
    void sendMessage ();
};

Mesh_PDP SensorsMesh;

Task taskSendMessage(TASK_SECOND * 5 , TASK_FOREVER, &(SensorsMesh.sendMessage));// Error

I can create a new function and use it, but I'm not happy with this solution.

void testfunction()
{
  SensorsMesh.sendMessage();
}

 //Create tasks: to send messages and get readings;
  Task taskSendMessage(TASK_SECOND * 5 , TASK_FOREVER, &testfunction);
  • 1
    Does this answer your question? [How do i write a pointer-to-member-function with std::function?](https://stackoverflow.com/questions/9281172/how-do-i-write-a-pointer-to-member-function-with-stdfunction) – Raymond Chen Feb 11 '23 at 23:14

0 Answers0