Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer
.
size_t remainingLength,
MQTTStatus_t MQTT_SerializeConnect(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer.
Definition: core_mqtt_serializer.c:1794
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
MQTT CONNECT packet parameters.
Definition: core_mqtt_serializer.h:145
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:135
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:214
MQTT_GetConnectPacketSize should be called with pConnectInfo
and pWillInfo
before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength
. The remainingLength
must be the same as returned by MQTT_GetConnectPacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetConnectPacketSize.
- Parameters
-
[in] | pConnectInfo | MQTT CONNECT packet parameters. |
[in] | pWillInfo | Last Will and Testament. Pass NULL if not used. |
[in] | remainingLength | Remaining Length provided by MQTT_GetConnectPacketSize. |
[out] | pFixedBuffer | Buffer for packet serialization. |
- Returns
- MQTTNoMemory if pFixedBuffer is too small to hold the MQTT packet; MQTTBadParameter if invalid parameters are passed; MQTTSuccess otherwise.
Example
uint8_t buffer[ BUFFER_SIZE ];
size_t remainingLength = 0, packetSize = 0;
fixedBuffer.
size = BUFFER_SIZE;
&connectInfo, &willInfo, &remainingLength, &packetSize
);
assert( packetSize <= BUFFER_SIZE );
{
}
MQTTStatus_t MQTT_GetConnectPacketSize(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, size_t *pRemainingLength, size_t *pPacketSize)
Get the size and Remaining Length of an MQTT CONNECT packet.
Definition: core_mqtt_serializer.c:1694
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:137
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:136