1.1.18.5 Publish Properties
Publish properties can be included when calling WDRV_WINC_MQTTPublish to publish to a topic or when calling WDRV_WINC_MQTTLWTSet to set the will message.
Publish properties can also be received in a PUBLISH message via the WDRV_WINC_MQTT_SUBSCRIBE_CALLBACK supplied to WDRV_WINC_MQTTSubscribe.
WDRV_WINC_MQTTPubPropDefaultSet is used to initialize a WDRV_WINC_MQTT_PUB_PROP structure, then the following functions can be used to set the selected properties:
| ID | Name | Set Function | Valid Values | Disable Value |
|---|---|---|---|---|
| 1 | Payload Format Indicator | WDRV_WINC_MQTTPubPropPayloadFormatSet | >0 | 0 |
| 2 | Message Expiry Interval | WDRV_WINC_MQTTPubPropMessageExpirySet | >0 | 0 |
| 3 | Content Type | WDRV_WINC_MQTTPubPropContentTypeSet | Valid String | NULL |
| 11 | Subscription Identifier | n/a | >0 | n/a |
| 24 | Will Delay Interval | WDRV_WINC_MQTTPubPropWillDelaySet | >0 | 0 |
| 35 | Topic Alias | WDRV_WINC_MQTTPubPropTopicAliasSet | >0 | 0 |
Setting a property value to its disable value will ensure the property is not included in the publish message.
Publishing to a Topic with Properties
Before calling WDRV_WINC_MQTTPublish a WDRV_WINC_MQTT_PUB_PROP structure can be initialized and functions used to populate each property. Calling WDRV_WINC_MQTTPublish will then cause those properties to be included.
The following properties are valid when calling WDRV_WINC_MQTTPublish:
Payload Format Indicator
Message Expiry Interval
Content Type
Topic Alias
WDRV_WINC_MQTT_MSG_INFO msgInfo; WDRV_WINC_MQTT_PUB_PROP pubProp; uint8_t topicData[5] = {1, 2, 3, 4, 5}; /* Initialize the message information structure to default values. */ WDRV_WINC_MQTTMsgInfoDefaultSet(&msgInfo); /* Initialize the publish property structure to default values. */ WDRV_WINC_MQTTPubPropDefaultSet(&pubProp); /* Set the Topic Alias property to 15. */ WDRV_WINC_MQTTPubPropTopicAliasSet(&pubProp, 15); /* Associate publish property structure with message information structure. */ WDRV_WINC_MQTTMsgInfoPubPropSet(&msgInfo, &pubProp); /* Publish 5 bytes of data to a topic with alias 15. */ WDRV_WINC_MQTTPublish(wdrvHandle, &msgInfo, NULL, topicData, sizeof(topicData), mqttPublishCallback, 0, NULL);
Will Message Properties
Before calling WDRV_WINC_MQTTLWTSet a WDRV_WINC_MQTT_PUB_PROP structure can be initialized and functions used to populate each property. Calling WDRV_WINC_MQTTLWTSet will then cause those properties to be included.
The following properties are valid when calling WDRV_WINC_MQTTLWTSet:
Payload Format Indicator
Message Expiry Interval
Content Type
Will Delay Interval
WDRV_WINC_MQTT_MSG_INFO msgInfo; WDRV_WINC_MQTT_PUB_PROP pubProp; uint8_t topicData[5] = {1, 2, 3, 4, 5}; /* Initialize the message information structure to default values. */ WDRV_WINC_MQTTMsgInfoDefaultSet(&msgInfo); /* Initialize the publish property structure to default values. */ WDRV_WINC_MQTTPubPropDefaultSet(&pubProp); /* Set the Will Delay property to 1500. */ WDRV_WINC_MQTTPubPropWillDelaySet(&pubProp, 1500); /* Associate publish property structure with message information structure. */ WDRV_WINC_MQTTMsgInfoPubPropSet(&msgInfo, &pubProp); /* Configure Will Message. */ WDRV_WINC_MQTTLWTSet(wdrvHandle, &msgInfo, "TopicName", topicData, sizeof(topicData));
Subscription Properties
When a PUBLISH message is received a WDRV_WINC_MQTT_SUBSCRIBE_CALLBACK callback registered with WDRV_WINC_MQTTSubscribe will be called, included may be the received publish properties.
The following properties are valid when receiving a PUBLISH message:
Payload Format Indicator
Message Expiry Interval
Content Type
Subscription Identifier
