eclipse / paho.mqtt.embedded-c

Paho MQTT C client library for embedded systems. Paho is an Eclipse IoT project (https://iot.eclipse.org/)

Home Page:https://eclipse.org/paho

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subscribing multiple topics

edonabz opened this issue · comments

#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?