adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
566 stars 292 forks source link

How to use to set callback to a class member function ? #198

Closed tavdog closed 3 years ago

tavdog commented 3 years ago

Is there a way to use the library inside of a class and then set a callback to be one of the class functions ? I can't figure out a way to do this ? It seems to work without a problem with the PubSubClient but I'd rather use this library because it it more robust when it comes to reconnecting. I'm using esp8266 with Arduino.

Screen Shot 2021-07-11 at 11 Sun 11 55 58 PM
brentru commented 3 years ago

Is there a way to use the library inside of a class and then set a callback to be one of the class functions ?

Nope, you'd need to make data_callback and command_callback globally scoped functions or static