Callback function pointer types of the MQTT library.
More...
|
typedef uint32_t(* | MQTTGetCurrentTimeFunc_t) (void) |
| Application provided function to query the current time in milliseconds. More...
|
|
typedef void(* | MQTTEventCallback_t) (struct MQTTContext *pContext, struct MQTTPacketInfo *pPacketInfo, struct MQTTDeserializedInfo *pDeserializedInfo) |
| Application callback for receiving incoming publishes and incoming acks. More...
|
|
typedef int32_t(* | TransportRecv_t) (NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv) |
| Transport interface for receiving data on the network. More...
|
|
typedef int32_t(* | TransportSend_t) (NetworkContext_t *pNetworkContext, const void *pBuffer, size_t bytesToSend) |
| Transport interface for sending data over the network. More...
|
|
Callback function pointer types of the MQTT library.
◆ MQTTGetCurrentTimeFunc_t
typedef uint32_t(* MQTTGetCurrentTimeFunc_t) (void) |
Application provided function to query the current time in milliseconds.
- Returns
- The current time in milliseconds.
◆ MQTTEventCallback_t
typedef void(* MQTTEventCallback_t) (struct MQTTContext *pContext, struct MQTTPacketInfo *pPacketInfo, struct MQTTDeserializedInfo *pDeserializedInfo) |
Application callback for receiving incoming publishes and incoming acks.
- Note
- This callback will be called only if packets are deserialized with a result of MQTTSuccess or MQTTServerRefused. The latter can be obtained when deserializing a SUBACK, indicating a broker's rejection of a subscribe.
- Parameters
-
[in] | pContext | Initialized MQTT context. |
[in] | pPacketInfo | Information on the type of incoming MQTT packet. |
[in] | pDeserializedInfo | Deserialized information from incoming packet. |
◆ TransportRecv_t
typedef int32_t(* TransportRecv_t) (NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv) |
Transport interface for receiving data on the network.
- Note
- It is RECOMMENDED that the transport receive implementation does NOT block when requested to read a single byte. A single byte read request can be made by the caller to check whether there is a new frame available on the network for reading. However, the receive implementation MAY block for a timeout period when it is requested to read more than 1 byte. This is because once the caller is aware that a new frame is available to read on the network, then the likelihood of reading more than one byte over the network becomes high.
- Parameters
-
[in] | pNetworkContext | Implementation-defined network context. |
[in] | pBuffer | Buffer to receive the data into. |
[in] | bytesToRecv | Number of bytes requested from the network. |
- Returns
- The number of bytes received or a negative value to indicate error.
- Note
- If no data is available on the network to read and no error has occurred, zero MUST be the return value. A zero return value SHOULD represent that the read operation can be retried by calling the API function. Zero MUST NOT be returned if a network disconnection has occurred.
◆ TransportSend_t
typedef int32_t(* TransportSend_t) (NetworkContext_t *pNetworkContext, const void *pBuffer, size_t bytesToSend) |
Transport interface for sending data over the network.
- Parameters
-
[in] | pNetworkContext | Implementation-defined network context. |
[in] | pBuffer | Buffer containing the bytes to send over the network stack. |
[in] | bytesToSend | Number of bytes to send over the network. |
- Returns
- The number of bytes sent or a negative value to indicate error.
- Note
- If no data is transmitted over the network due to a full TX buffer and no network error has occurred, this MUST return zero as the return value. A zero return value SHOULD represent that the send operation can be retried by calling the API function. Zero MUST NOT be returned if a network disconnection has occurred.