I have a program that depending on user input, it creates one or several objects that will publish data to a MQTT broker, each one with a different topic. This is already done. The ESP8266 also has subscribe itself to the same topics it publishes. Now, the problem is that I have to create a dynamic callback in the ESP8266 to read the all the posible arriving topics to which the ESP8266 has subscribed and I am having trouble with that.
The callback function model is:
void MQTTcallback(char* topic, byte* payload, unsigned int length) {
// handle message arrived
}
The possible topics can be:
ObjectTL/TL_1
ObjectTL/TL_2
ObjectTL/TL_3
...
ObjectTL/TL_X
The number (TL_X) depends of the user input I mention at the beginning. Thanks!