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:

IDNameSet FunctionValid ValuesDisable Value
1Payload Format IndicatorWDRV_WINC_MQTTPubPropPayloadFormatSet>00
2Message Expiry IntervalWDRV_WINC_MQTTPubPropMessageExpirySet>00
3Content TypeWDRV_WINC_MQTTPubPropContentTypeSetValid StringNULL
11Subscription Identifiern/a>0n/a
24Will Delay IntervalWDRV_WINC_MQTTPubPropWillDelaySet>00
35Topic AliasWDRV_WINC_MQTTPubPropTopicAliasSet>00

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