1.1.18.9.5 WDRV_WINC_MQTTPublish

C

WDRV_WINC_STATUS WDRV_WINC_MQTTPublish
(
    DRV_HANDLE handle,
    const WDRV_WINC_MQTT_MSG_INFO *pMsgInfo,
    const char *pTopicName,
    const uint8_t *pTopicData,
    size_t topicDataLen,
    WDRV_WINC_MQTT_PUB_STATUS_CALLBACK pfPubStatusCb,
    uintptr_t pubStatusCbCtx,
    WDRV_WINC_MQTT_PUB_HANDLE *pPubHandle
)

Description

Publishes a message to an MQTT topic.

Precondition

WDRV_WINC_Initialize must have been called.

WDRV_WINC_Open must have been called to obtain a valid handle.

Parameters

ParametersDescription
handleClient handle obtained by a call to WDRV_WINC_Open.
pMsgInfoPointer to message information if required.
pTopicNamePointer to topic name.
pTopicDataPointer to data to publish to topic.
topicDataLenLength of data to publish.
pfPubStatusCbPointer to publish status callback.
pubStatusCbCtxUser context to be passed to callback when called.
pPubHandlePointer to handle to receive short term publish handle.

Returns

  • WDRV_WINC_STATUS_OK - A publish was sent.

  • WDRV_WINC_STATUS_NOT_OPEN - The driver instance is not open.

  • WDRV_WINC_STATUS_REQUEST_ERROR - The request to the WINC was rejected.

  • WDRV_WINC_STATUS_INVALID_ARG - The parameters were incorrect.

Remarks

The publish handle returned is only valid until the callback is called with both a handle and a packet ID, after which the handle is no longer valid and should be discarded. Further updates to the callback will use the packet ID. This is only relevant to QoS 1 and 2.

To use topic aliases in MQTT V5 a publish must be sent first with both pTopicName and pMsgInfo->pProperties->topicAlias being valid. Once the alias is registered with the broker WDRV_WINC_MQTTPublish can be called with pTopicName equal to NULL as long as pMsgInfo->pProperties->topicAlias is set to the registered alias ID.