Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 Support for Method Pointers #143

Open
ZanzyTHEbar opened this issue Feb 26, 2023 · 0 comments
Open

ESP32 Support for Method Pointers #143

ZanzyTHEbar opened this issue Feb 26, 2023 · 0 comments
Labels
selected for development Feature will be implemented in the next version

Comments

@ZanzyTHEbar
Copy link

ZanzyTHEbar commented Feb 26, 2023

Hello, i am using this library, and i am having to re-write the call backs to support std::function on the ESP devices.

In my project, i have created a HASSMQTT class for handling all of my HAMqtt logic. Normally, i would use a lambda or std::bind to a callback which has a std::function based type.

I would really like this functionality - but i can't in the default library as you only except function pointers, and not method pointers (on supported boards).

I would recommend doing something like:

#ifdef ESP32
#include <functional>
#define HASWITCH_CALLBACK(name) std::function<void(bool state, HASwitch* s)> name
#else
#ifdef ESP8266
#include <functional>
#define HASWITCH_CALLBACK(name) std::function<void(bool state, HASwitch* s)> name
#endif
#define HASWITCH_CALLBACK(name) void (*name)(bool, HASwitch*)
#endif

Now, of course the std::function is available for all 32bit boards, so adding support for all 32bit boards using a single preprocessor macro is preferred.

@dawidchyrzynski dawidchyrzynski added the selected for development Feature will be implemented in the next version label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
selected for development Feature will be implemented in the next version
Projects
None yet
Development

No branches or pull requests

2 participants