ARMmbed / mbed-mqtt

Mbed-os MQTT and MQTT-SN library, based on Eclipse Paho project.
Other
47 stars 26 forks source link

MQTT subscribe don't dispatch topic callback. #39

Closed phlegx closed 2 years ago

phlegx commented 2 years ago

Hi! I use the latest mbed-mqtt (master) library. The topic should be composed from a variable and passed to the subscribe function like this:

char topic[128];
snprintf(topic, 128, "PR/test/%s/+", mqttd_channel);
mqttc.subscribe((const char *)topic, MQTT::QOS2, callbackFc);

From my device I can see incoming cellular data from AT debug, but the MQTT client don't dispatch the callback. If I set the topic directly, the dispatch works fine:

mqttc.subscribe((const char *)"PR/test/c1/+", MQTT::QOS2, callbackFc);

Any idea what I'm doing wrong?

phlegx commented 2 years ago

The pointer of topic was gone. Now I have declared the topic on my object instance and all works fine. My bad!