eclipse-paho / paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)
https://eclipse.org/paho
Other
1.37k stars 758 forks source link

Subscribing multiple topics #189

Open edonabz opened 5 years ago

edonabz commented 5 years ago

Hi

I'm porting this library to a mbed Microchip project to connect to Google Cloud IoT core. [see example https://github.com/MicrochipTech/gcp-iot-core-examples]

I can subscribe one topic, e.g. "config", but no way to handle simultaneous subscription to 2 different topics (same broker), as supported in full Paho MQTT.

`static int client_subscribe_commands(void pCtx) { struct _g_client_context ctx2 = (struct _g_client_context*)pCtx; int status = MQTTCLIENT_FAILURE;

//////Subscribe al topic commands       config_get_client_commands_topic
status = config_get_client_commands_topic((char*)ctx2->sub_topic, sizeof(ctx2->sub_topic));
if (status != MQTTCLIENT_SUCCESS)
{
    CLIENT_PRINTF("Failed to load the commands topic name");
    return status;
}
status = MQTTSubscribe(&ctx2->mqtt_client, ctx2->sub_topic, QOS1, &client_process_commands);
//////

return status;

}`

Any suggestion?