ESP8266 Arduino MQTT callback with dynamic topics 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!
I think using sscanf may help you

void MQTTcallback(char* topic, byte* payload, unsigned int length) {

  sscanf(data, "ObjectTL/TL_%d", dynamicTopicName);
  // handle message arrived
  your_dynamic_function(dynamicTopicName,byte* payload, unsigned int length)

}