dersimn / ArduinoPubSubClientTools

11 stars 3 forks source link

How I can call funtions callback into a Class #4

Open GiovaniSchreiber opened 4 years ago

GiovaniSchreiber commented 4 years ago

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 commented 4 years ago

This library already does it in the .h file, just implement something similar in your own code: https://github.com/dersimn/ArduinoPubSubClientTools/blob/bd93920665ffd80469324dd14949d2f20b21cea5/PubSubClientTools.h#L41

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

GiovaniSchreiber commented 4 years ago

thanks