1.2.3.19 SYS_MQTT_Subscribe Function

C

int32_t SYS_MQTT_Subscribe(SYS_MODULE_OBJ obj,
SYS_MQTT_SubscribeConfig *subConfig);

Summary

Returns success/ failure for the subscribing to a Topic by the user.

Description

This function is used for subscribing to a Topic.

Precondition

SYS_MQTT_Connect should have been called before calling this function

Parameters

ParamDescription
objSYS MQTT object handle, returned from SYS_MQTT_Connect subConfig - valid pointer to the Topic details on which to Subscribe

Returns

SYS_MQTT_SUCCESS - Indicates that the Request was catered to successfully

SYS_MQTT_FAILURE - Indicates that the Request failed

Example

SYS_MQTT_SubscribeConfig		sSubscribeCfg;

memset(&sSubscribeCfg, 0, sizeof(sSubscribeCfg));
sSubscribeCfg.qos = 1;
strcpy(sSubscribeCfg.topicName, "house/temperature/first_floor/kitchen");

// Handle "objSysMqtt" value must have been returned from SYS_MQTT_Connect.
if( SYS_MQTT_Subscribe(objSysMqtt, &sSubscribeCfg) == SYS_MQTT_SUCCESS)
{
}