uint32_t remainingLength,
MQTTStatus_t MQTT_SerializeConnect(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, const MQTTPropBuilder_t *pConnectProperties, const MQTTPropBuilder_t *pWillProperties, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer.
Definition: core_mqtt_serializer.c:3428
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:239
MQTT CONNECT packet parameters.
Definition: core_mqtt_serializer.h:294
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:284
Property builder for MQTT packets.
Definition: core_mqtt_serializer.h:470
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:395
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer.
MQTT_GetConnectPacketSize should be called with pConnectInfo, pWillInfo, pConnectProperties, and pWillProperties 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] | pConnectProperties | MQTT CONNECT properties builder. Pass NULL if not used. |
| [in] | pWillProperties | MQTT Will properties builder. 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, &connectionProperties, &willProperties,
&remainingLength, &packetSize
);
assert( packetSize <= BUFFER_SIZE );
&connectInfo,
&willInfo,
&connectionProperties,
&willProperties,
remainingLength,
&fixedBuffer
);
{
}
MQTTStatus_t MQTT_GetConnectPacketSize(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, const MQTTPropBuilder_t *pConnectProperties, const MQTTPropBuilder_t *pWillProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize)
Get the size and Remaining Length of an MQTT Version 5 CONNECT packet.
Definition: core_mqtt_serializer.c:3097
@ MQTTSuccess
Definition: core_mqtt_serializer.h:240
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:286
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:285