@@ -243,15 +243,64 @@ typedef int32_t ( * TransportSend_t )( NetworkContext_t * pNetworkContext,
243
243
size_t bytesToSend );
244
244
/* @[define_transportsend] */
245
245
246
+ /**
247
+ * @brief Transport vector structure for sending multiple messages.
248
+ */
249
+ typedef struct TransportOutVector
250
+ {
251
+ /**
252
+ * @brief Base address of data.
253
+ */
254
+ const void * iov_base ;
255
+
256
+ /**
257
+ * @brief Length of data in buffer.
258
+ */
259
+ size_t iov_len ;
260
+ } TransportOutVector_t ;
261
+
262
+ /**
263
+ * @transportcallback
264
+ * @brief Transport interface function for "vectored" / scatter-gather based
265
+ * writes. This function is expected to iterate over the list of vectors pIoVec
266
+ * having ioVecCount entries containing portions of one MQTT message at a maximum.
267
+ * If the proper functionality is available, then the data in the list should be
268
+ * copied to the underlying TCP buffer before flushing the buffer. Implementing it
269
+ * in this fashion will lead to sending of fewer TCP packets for all the values
270
+ * in the list.
271
+ *
272
+ * @note If the proper write functionality is not present for a given device/IP-stack,
273
+ * then there is no strict requirement to implement write. Only the send and recv
274
+ * interfaces must be defined for the application to work properly.
275
+ *
276
+ * @param[in] pNetworkContext Implementation-defined network context.
277
+ * @param[in] pIoVec An array of TransportIoVector_t structs.
278
+ * @param[in] ioVecCount Number of TransportIoVector_t in pIoVec.
279
+ *
280
+ * @return The number of bytes written or a negative value to indicate error.
281
+ *
282
+ * @note If no data is written to the buffer due to the buffer being full this MUST
283
+ * return zero as the return value.
284
+ * A zero return value SHOULD represent that the write operation can be retried
285
+ * by calling the API function. Zero MUST NOT be returned if a network disconnection
286
+ * has occurred.
287
+ */
288
+ /* @[define_transportwritev] */
289
+ typedef int32_t ( * TransportWritev_t )( NetworkContext_t * pNetworkContext ,
290
+ TransportOutVector_t * pIoVec ,
291
+ size_t ioVecCount );
292
+ /* @[define_transportwritev] */
293
+
246
294
/**
247
295
* @transportstruct
248
296
* @brief The transport layer interface.
249
297
*/
250
298
/* @[define_transportinterface] */
251
299
typedef struct TransportInterface
252
300
{
253
- TransportRecv_t recv ; /**< Transport receive interface. */
254
- TransportSend_t send ; /**< Transport send interface. */
301
+ TransportRecv_t recv ; /**< Transport receive function pointer. */
302
+ TransportSend_t send ; /**< Transport send function pointer. */
303
+ TransportWritev_t writev ; /**< Transport writev function pointer. */
255
304
NetworkContext_t * pNetworkContext ; /**< Implementation-defined network context. */
256
305
} TransportInterface_t ;
257
306
/* @[define_transportinterface] */
0 commit comments