C++ event handler functions as member functions

teodor12
Posts: 2
Joined: Sun Apr 28, 2024 4:27 pm

C++ event handler functions as member functions

Postby teodor12 » Sun Jul 07, 2024 10:17 am

Is there any other way to register event handler functions in WifiHandler class? I do not want to make them static. I attached the files of the my component.

Thank you!
Attachments
CMakeLists.txt
(213 Bytes) Downloaded 33 times
WifiHandler.hpp
(2.47 KiB) Downloaded 32 times
WifiHandler.cpp
(11.29 KiB) Downloaded 32 times

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: C++ event handler functions as member functions

Postby MicroController » Mon Jul 08, 2024 9:02 am

Use a static 'adapter' function and the user-provided void* argument of the event callback to route the callback to a non-static member function like e.g. here:
https://esp32.com/viewtopic.php?f=13&t=40146#p132955

Who is online

Users browsing this forum: No registered users and 101 guests