Sends MQTT SUBSCRIBE for the given list of topic filters to the broker.
size_t subscriptionCount,
uint16_t packetId );
MQTTStatus_t MQTT_Subscribe(MQTTContext_t *pContext, const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, uint16_t packetId)
Sends MQTT SUBSCRIBE for the given list of topic filters to the broker.
Definition: core_mqtt.c:2698
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
A struct representing an MQTT connection.
Definition: core_mqtt.h:162
MQTT SUBSCRIBE packet parameters.
Definition: core_mqtt_serializer.h:192
- Parameters
-
[in] | pContext | Initialized MQTT context. |
[in] | pSubscriptionList | Array of MQTT subscription info. |
[in] | subscriptionCount | The number of elements in @ pSubscriptionList array. |
[in] | packetId | Packet ID generated by MQTT_GetPacketId. |
- Returns
- MQTTNoMemory if the MQTTContext_t.networkBuffer is too small to hold the MQTT packet; MQTTBadParameter if invalid parameters are passed; MQTTSendFailed if transport write failed; MQTTSuccess otherwise.
Example
uint16_t packetId;
const char * filters[ NUMBER_OF_SUBSCRIPTIONS ];
for( int i = 0; i < NUMBER_OF_SUBSCRIPTIONS; i++ )
{
}
status =
MQTT_Subscribe( pContext, &subscriptionList[ 0 ], NUMBER_OF_SUBSCRIPTIONS, packetId );
{
}
uint16_t MQTT_GetPacketId(MQTTContext_t *pContext)
Get a packet ID that is valid according to the MQTT 3.1.1 spec.
Definition: core_mqtt.c:3099
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
@ MQTTQoS0
Definition: core_mqtt_serializer.h:122
MQTTQoS_t qos
Quality of Service for subscription.
Definition: core_mqtt_serializer.h:196
uint16_t topicFilterLength
Length of subscription topic filter.
Definition: core_mqtt_serializer.h:206
const char * pTopicFilter
Topic filter to subscribe to.
Definition: core_mqtt_serializer.h:201