Topic: Subscribe To Several Topics

Hi Forum,

Is it possible to subscribe to several topics ?

Any example will be appreciated.

Thank you.

Share

Re: Subscribe To Several Topics

Hi rlev,

Yes, when using the MqttClient_Subscribe API to subscribe, you can pass as many topics as you'd like in the array MqttSubscribe->topics as long as you set topic_count correctly.
Here are a couple of examples that subscribe to a single topic, to expand them you'd just iterate over each topic and set their parameters accordingly:
https://github.com/wolfSSL/wolfMQTT/blo … ent.c#L383
https://github.com/wolfSSL/wolfMQTT/blo … ple.c#L399

Thanks,
Kareem

Share