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

How I can call funtions callback into a Class #4

Open
GiovaniSchreiber opened this issue Dec 22, 2019 · 2 comments
Open

How I can call funtions callback into a Class #4

GiovaniSchreiber opened this issue Dec 22, 2019 · 2 comments

Comments

@GiovaniSchreiber
Copy link

I am trying to call the function "callback" into a Class, but it not work.

PubSubClientTools *clientMQTT;

......
clientMQTT->subscribe(TOPICO_SUBSCRIBE_CM_LAMP, MQTTClass::subscriber);//the problem is here
//clientMQTT->subscribe(TOPICO_SUBSCRIBE_CM_LAMP, std::bind(&MQTTClass::subscriber, this);//not work too
..........
void MQTTClass::subscriber(String topic, String message) {
MQTT_Call_buttonPress(bool(message), MQTT_S);
}
Does anyone know how I do it?

@dersimn
Copy link
Owner

dersimn commented Feb 26, 2020

This library already does it in the .h file, just implement something similar in your own code:

std::function<void(PUBSUBCLIENT_CALLBACK_PARAMETERS)> mqtt_callback = std::bind(&PubSubClientTools::callback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);

Afaik the std::* things are only available on ESP8266, not AVR platform.

@GiovaniSchreiber
Copy link
Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants