This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mqtt subscripe multiple topics

Hi guys,

In the iot sdk in mqtt.h there are typdefs for "mqtt_topic_t " and "mqtt_subscription_list_t". I'm trying to set several topics (5) and subscribe to them.

Meaning I wanna call the mqtt_subscribe() funtion with the subscription_list.list_count set to 5. But I don't understand how I would have to pass the pointer of the topics to subscription_list.p_list.

Do I have to go with this approach

devzone.nordicsemi.com/.../

or can I actually pass all the topic in one package?

Cheers Timur

mqtt_topic_t mqtt_subscription_topic_specs; mqtt_subscription_list_t subscription_list;

subscription_list.p_list = &mqtt_subscription_topic_specs; subscription_list.list_count = 1; subscription_list.message_id = APP_MQTT_SUBSCRIPTION_PKT_ID;

err_code = mqtt_subscribe(&m_app_mqtt_id, &subscription_list);

Related