@@ -102,7 +102,7 @@ typedef void (* MQTTEventCallback_t )( struct MQTTContext * pContext,
102
102
struct MQTTDeserializedInfo * pDeserializedInfo );
103
103
104
104
/**
105
- * @brief User defined API used to store outgoing publishes. Used to track any publish
105
+ * @brief User defined callback used to store outgoing publishes. Used to track any publish
106
106
* retransmit on an unclean session connection.
107
107
*
108
108
* @param[in] pContext Initialised MQTT Context.
@@ -113,14 +113,14 @@ typedef void (* MQTTEventCallback_t )( struct MQTTContext * pContext,
113
113
* @return True if the copy is successful else false.
114
114
*/
115
115
/* @[define_mqtt_retransmitstorepacket] */
116
- typedef bool ( * MQTTRetransmitStorePacket )( struct MQTTContext * pContext ,
117
- uint16_t packetId ,
118
- TransportOutVector_t * pIoVec ,
119
- size_t ioVecCount );
116
+ typedef bool ( * MQTTStorePacketForRetransmit )( struct MQTTContext * pContext ,
117
+ uint16_t packetId ,
118
+ TransportOutVector_t * pIoVec ,
119
+ size_t ioVecCount );
120
120
/* @[define_mqtt_retransmitstorepacket] */
121
121
122
122
/**
123
- * @brief User defined API used to retreive a copied publish for resend operation. Used to
123
+ * @brief User defined callback used to retreive a copied publish for resend operation. Used to
124
124
* track any publish retransmit on an unclean session connection.
125
125
*
126
126
* @param[in] pContext Initialised MQTT Context.
@@ -131,14 +131,14 @@ typedef bool ( * MQTTRetransmitStorePacket)( struct MQTTContext * pContext,
131
131
* @return True if the retreive is successful else false.
132
132
*/
133
133
/* @[define_mqtt_retransmitretrievepacket] */
134
- typedef bool ( * MQTTRetransmitRetrievePacket )( struct MQTTContext * pContext ,
135
- uint16_t packetId ,
136
- TransportOutVector_t * * pIoVec ,
137
- size_t * ioVecCount );
134
+ typedef bool ( * MQTTRetrievePacketForRetransmit )( struct MQTTContext * pContext ,
135
+ uint16_t packetId ,
136
+ TransportOutVector_t * * pIoVec ,
137
+ size_t * ioVecCount );
138
138
/* @[define_mqtt_retransmitretrievepacket] */
139
139
140
140
/**
141
- * @brief User defined API used to clear a particular copied publish packet. Used to
141
+ * @brief User defined callback used to clear a particular copied publish packet. Used to
142
142
* track any publish retransmit on an unclean session connection.
143
143
*
144
144
* @param[in] pContext Initialised MQTT Context.
@@ -147,20 +147,20 @@ typedef bool ( * MQTTRetransmitRetrievePacket)( struct MQTTContext * pContext,
147
147
* @return True if the clear is successful else false.
148
148
*/
149
149
/* @[define_mqtt_retransmitclearpacket] */
150
- typedef bool (* MQTTRetransmitClearPacket )( struct MQTTContext * pContext ,
151
- uint16_t packetId );
150
+ typedef bool (* MQTTClearPacketForRetransmit )( struct MQTTContext * pContext ,
151
+ uint16_t packetId );
152
152
/* @[define_mqtt_retransmitclearpacket] */
153
153
154
154
/**
155
- * @brief User defined API used to clear all copied publish packets. Used to
155
+ * @brief User defined callback used to clear all copied publish packets. Used to
156
156
* when connecting with a clean session.
157
157
*
158
158
* @param[in] pContext Initialised MQTT Context.
159
159
*
160
160
* @return True if the clear all is successful else false.
161
161
*/
162
162
/* @[define_mqtt_retransmitclearallpackets] */
163
- typedef bool (* MQTTRetransmitClearAllPackets )( struct MQTTContext * pContext );
163
+ typedef bool (* MQTTClearAllPacketsForRetransmit )( struct MQTTContext * pContext );
164
164
/* @[define_mqtt_retransmitclearallpackets] */
165
165
166
166
/**
@@ -313,22 +313,22 @@ typedef struct MQTTContext
313
313
/**
314
314
* @brief User defined API used to store outgoing publishes.
315
315
*/
316
- MQTTRetransmitStorePacket storeFunction ;
316
+ MQTTStorePacketForRetransmit storeFunction ;
317
317
318
318
/**
319
319
* @brief User defined API used to retreive a copied publish for resend operation.
320
320
*/
321
- MQTTRetransmitRetrievePacket retrieveFunction ;
321
+ MQTTRetrievePacketForRetransmit retrieveFunction ;
322
322
323
323
/**
324
324
* @brief User defined API used to clear a particular copied publish packet.
325
325
*/
326
- MQTTRetransmitClearPacket clearFunction ;
326
+ MQTTClearPacketForRetransmit clearFunction ;
327
327
328
328
/**
329
329
* @brief User defined API used to clear all copied publish packets.
330
330
*/
331
- MQTTRetransmitClearAllPackets clearAllFunction ;
331
+ MQTTClearAllPacketsForRetransmit clearAllFunction ;
332
332
} MQTTContext_t ;
333
333
334
334
/**
@@ -510,16 +510,86 @@ MQTTStatus_t MQTT_InitStatefulQoS( MQTTContext_t * pContext,
510
510
*
511
511
* @return #MQTTBadParameter if invalid parameters are passed;
512
512
* #MQTTSuccess otherwise.
513
+ *
514
+ * <b>Example</b>
515
+ * @code{c}
516
+ *
517
+ * // Function for obtaining a timestamp.
518
+ * uint32_t getTimeStampMs();
519
+ * // Callback function for receiving packets.
520
+ * void eventCallback(
521
+ * MQTTContext_t * pContext,
522
+ * MQTTPacketInfo_t * pPacketInfo,
523
+ * MQTTDeserializedInfo_t * pDeserializedInfo
524
+ * );
525
+ * // Network send.
526
+ * int32_t networkSend( NetworkContext_t * pContext, const void * pBuffer, size_t bytes );
527
+ * // Network receive.
528
+ * int32_t networkRecv( NetworkContext_t * pContext, void * pBuffer, size_t bytes );
529
+ * // User defined callback used to store outgoing publishes
530
+ * bool publishStoreCallback(struct MQTTContext* pContext,
531
+ * uint16_t packetId,
532
+ * TransportOutVector_t* pIoVec,
533
+ * size_t ioVecCount);
534
+ * // User defined callback used to retreive a copied publish for resend operation
535
+ * bool publishRetrieveCallback(struct MQTTContext* pContext,
536
+ * uint16_t packetId,
537
+ * TransportOutVector_t** pIoVec,
538
+ * size_t* ioVecCount);
539
+ * // User defined callback used to clear a particular copied publish packet
540
+ * bool publishClearCallback(struct MQTTContext* pContext,
541
+ * uint16_t packetId);
542
+ * // User defined callback used to clear all copied publish packets
543
+ * bool publishClearAllCallback(struct MQTTContext* pContext);
544
+ *
545
+ * MQTTContext_t mqttContext;
546
+ * TransportInterface_t transport;
547
+ * MQTTFixedBuffer_t fixedBuffer;
548
+ * uint8_t buffer[ 1024 ];
549
+ * const size_t outgoingPublishCount = 30;
550
+ * MQTTPubAckInfo_t outgoingPublishes[ outgoingPublishCount ];
551
+ *
552
+ * // Clear context.
553
+ * memset( ( void * ) &mqttContext, 0x00, sizeof( MQTTContext_t ) );
554
+ *
555
+ * // Set transport interface members.
556
+ * transport.pNetworkContext = &someTransportContext;
557
+ * transport.send = networkSend;
558
+ * transport.recv = networkRecv;
559
+ *
560
+ * // Set buffer members.
561
+ * fixedBuffer.pBuffer = buffer;
562
+ * fixedBuffer.size = 1024;
563
+ *
564
+ * status = MQTT_Init( &mqttContext, &transport, getTimeStampMs, eventCallback, &fixedBuffer );
513
565
*
566
+ * if( status == MQTTSuccess )
567
+ * {
568
+ * // We do not expect any incoming publishes in this example, therefore the incoming
569
+ * // publish pointer is NULL and the count is zero.
570
+ * status = MQTT_InitStatefulQoS( &mqttContext, outgoingPublishes, outgoingPublishCount, NULL, 0 );
571
+ *
572
+ * // Now QoS1 and/or QoS2 publishes can be sent with this context.
573
+ * }
574
+ *
575
+ * if( status == MQTTSuccess )
576
+ * {
577
+ * status = MQTT_InitRetransmits( &mqttContext, publishStoreCallback,
578
+ * publishRetrieveCallback,
579
+ * publishClearCallback,
580
+ * publishClearAllCallback );
581
+ *
582
+ * // Now unacked Publishes can be resent on an unclean session resumption.
583
+ * }
514
584
* @endcode
515
585
*/
516
586
517
587
/* @[declare_mqtt_initretransmits] */
518
588
MQTTStatus_t MQTT_InitRetransmits ( MQTTContext_t * pContext ,
519
- MQTTRetransmitStorePacket storeFunction ,
520
- MQTTRetransmitRetrievePacket retrieveFunction ,
521
- MQTTRetransmitClearPacket clearFunction ,
522
- MQTTRetransmitClearAllPackets clearAllFunction );
589
+ MQTTStorePacketForRetransmit storeFunction ,
590
+ MQTTRetrievePacketForRetransmit retrieveFunction ,
591
+ MQTTClearPacketForRetransmit clearFunction ,
592
+ MQTTClearAllPacketsForRetransmit clearAllFunction );
523
593
/* @[declare_mqtt_initretransmits] */
524
594
525
595
/**
0 commit comments