@@ -925,16 +925,28 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext,
925925 * @param[in] pContext Initialized MQTT context.
926926 * @param[in] pPublishInfo MQTT PUBLISH packet parameters.
927927 * @param[in] packetId packet ID generated by #MQTT_GetPacketId.
928+ * @param[in] pPropertyBuilder Properties to be sent in the outgoing packet.
928929 *
929- * @return #MQTTNoMemory if pBuffer is too small to hold the MQTT packet;
930- * #MQTTBadParameter if invalid parameters are passed;
931- * #MQTTSendFailed if transport write failed;
932- * #MQTTStatusNotConnected if the connection is not established yet
930+ * @return
931+ * #MQTTBadParameter if invalid parameters are passed;<br>
932+ * #MQTTBadResponse if there is an error in property parsing;<br>
933+ * #MQTTSendFailed if transport write failed;<br>
934+ * #MQTTStatusNotConnected if the connection is not established yet<br>
933935 * #MQTTStatusDisconnectPending if the user is expected to call MQTT_Disconnect
934- * before calling any other API
936+ * before calling any other API<br>
935937 * #MQTTPublishStoreFailed if the user provided callback to copy and store the
936- * outgoing publish packet fails
937- * #MQTTSuccess otherwise.
938+ * outgoing publish packet fails<br>
939+ * #MQTTSuccess otherwise.<br>
940+ *
941+ * Functions to add optional properties to the PUBLISH packet are:
942+ *
943+ * - #MQTTPropAdd_PubPayloadFormat
944+ * - #MQTTPropAdd_PubMessageExpiry
945+ * - #MQTTPropAdd_PubTopicAlias
946+ * - #MQTTPropAdd_PubResponseTopic
947+ * - #MQTTPropAdd_PubCorrelationData
948+ * - #MQTTPropAdd_PubContentType
949+ * - #MQTTPropAdd_UserProp
938950 *
939951 * <b>Example</b>
940952 * @code{c}
@@ -952,11 +964,19 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext,
952964 * publishInfo.topicNameLength = strlen( publishInfo.pTopicName );
953965 * publishInfo.pPayload = "Hello World!";
954966 * publishInfo.payloadLength = strlen( "Hello World!" );
967+ * // Optional properties to be sent in the PUBLISH packet.
968+ * MQTTPropBuilder_t propertyBuilder;
969+ * uint8_t propertyBuffer[ 100 ];
970+ * size_t propertyBufferLength = sizeof( propertyBuffer );
971+ * status = MQTTPropertyBuilder_Init( &propertyBuilder, propertyBuffer, propertyBufferLength );
972+ *
973+ * // Set a property in the propertyBuilder
974+ * status = MQTTPropAdd_PubPayloadFormat( &propertyBuilder, 1);
955975 *
956976 * // Packet ID is needed for QoS > 0.
957977 * packetId = MQTT_GetPacketId( pContext );
958978 *
959- * status = MQTT_Publish( pContext, &publishInfo, packetId );
979+ * status = MQTT_Publish( pContext, &publishInfo, packetId, &propertyBuilder );
960980 *
961981 * if( status == MQTTSuccess )
962982 * {
@@ -968,7 +988,8 @@ MQTTStatus_t MQTT_Subscribe( MQTTContext_t * pContext,
968988/* @[declare_mqtt_publish] */
969989MQTTStatus_t MQTT_Publish ( MQTTContext_t * pContext ,
970990 const MQTTPublishInfo_t * pPublishInfo ,
971- uint16_t packetId );
991+ uint16_t packetId ,
992+ const MQTTPropBuilder_t * pPropertyBuilder );
972993/* @[declare_mqtt_publish] */
973994
974995/**
@@ -1392,6 +1413,30 @@ void MQTT_SerializeMQTTVec( uint8_t * pAllocatedMem,
13921413 const MQTTVec_t * pVec );
13931414/* @[declare_mqtt_serializemqttvec] */
13941415
1416+ /**
1417+ * @brief Get a human-readable string representation of an MQTT packet type.
1418+ *
1419+ * This function converts an MQTT packet type byte into a corresponding
1420+ * string representation for debugging and logging purposes.
1421+ *
1422+ * @param[in] packetType The MQTT packet type byte to convert.
1423+ *
1424+ * @return A pointer to a constant string containing the packet type name.
1425+ * Returns "UNKNOWN" if the packet type is not recognized.
1426+ *
1427+ * @note The returned string is statically allocated and should not be freed.
1428+ * @note For PUBLISH packets, the function masks the lower 4 bits (flags) and
1429+ * returns "PUBLISH" regardless of the QoS, DUP, or RETAIN flag values.
1430+ *
1431+ * <b>Example</b>
1432+ * @code{c}
1433+ * uint8_t packetType = MQTT_PACKET_TYPE_PUBLISH;
1434+ * const char * packetName = MQTT_GetPacketTypeString( packetType );
1435+ * printf( "Received packet: %s\n", packetName ); // Prints "Received packet: PUBLISH"
1436+ * @endcode
1437+ */
1438+ const char * MQTT_GetPacketTypeString ( uint8_t packetType );
1439+
13951440/* *INDENT-OFF* */
13961441#ifdef __cplusplus
13971442 }
0 commit comments