Microchip® Advanced Software Framework

AWS_SDK/AWS_SDK/aws_mqtt_embedded_client_lib/MQTTPacket/src/MQTTConnectClient.c File Reference
#include "MQTTPacket.h"
#include "StackTrace.h"
#include <string.h>

Functions

MQTTReturnCode MQTTDeserialize_connack (unsigned char *sessionPresent, MQTTReturnCode *connack_rc, unsigned char *buf, size_t buflen)
 Deserializes the supplied (wire) buffer into connack data - return code. More...
 
MQTTReturnCode MQTTSerialize_connect (unsigned char *buf, size_t buflen, MQTTPacket_connectData *options, uint32_t *serialized_len)
 Serializes the connect options into the buffer. More...
 
MQTTReturnCode MQTTSerialize_disconnect (unsigned char *buf, size_t buflen, uint32_t *serialized_length)
 Serializes a disconnect packet into the supplied buffer, ready for writing to a socket. More...
 
size_t MQTTSerialize_GetConnectLength (MQTTPacket_connectData *options)
 Determines the length of the MQTT connect packet that would be produced using the supplied connect options. More...
 
MQTTReturnCode MQTTSerialize_pingreq (unsigned char *buf, size_t buflen, uint32_t *serialized_length)
 Serializes a pingreq packet into the supplied buffer, ready for writing to a socket. More...
 
MQTTReturnCode MQTTSerialize_zero (unsigned char *buf, size_t buflen, unsigned char packetType, uint32_t *serialized_length)
 Serializes a 0-length packet into the supplied buffer, ready for writing to a socket. More...
 

MQTTReturnCode MQTTDeserialize_connack ( unsigned char *  sessionPresent,
MQTTReturnCode connack_rc,
unsigned char *  buf,
size_t  buflen 
)

Deserializes the supplied (wire) buffer into connack data - return code.

Parameters
sessionPresentthe session present flag returned (only for MQTT 3.1.1)
connack_rcreturned integer value of the connack return code
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
MQTTReturnCode indicating function execution status

References MQTTConnackFlags::all, MQTTHeader::bits, MQTTConnackFlags::bits, buf, MQTTHeader::byte, CONANCK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR, CONNACK, CONNACK_BAD_USERDATA_ERROR, CONNACK_CONNECTION_ACCEPTED, CONNACK_IDENTIFIER_REJECTED_ERROR, CONNACK_NOT_AUTHORIZED_ERROR, CONNACK_SERVER_UNAVAILABLE_ERROR, FAILURE, FUNC_ENTRY, FUNC_EXIT_RC, header, MQTT_CONANCK_UNACCEPTABLE_PROTOCOL_VERSION_ERROR, MQTT_CONNACK_BAD_USERDATA_ERROR, MQTT_CONNACK_CONNECTION_ACCEPTED, MQTT_CONNACK_IDENTIFIER_REJECTED_ERROR, MQTT_CONNACK_NOT_AUTHORIZED_ERROR, MQTT_CONNACK_SERVER_UNAVAILABLE_ERROR, MQTT_CONNACK_UNKNOWN_ERROR, MQTT_NULL_VALUE_ERROR, MQTTPACKET_BUFFER_TOO_SHORT, MQTTPacket_decodeBuf(), NULL, readChar(), MQTTConnackFlags::sessionpresent, SUCCESS, and MQTTHeader::type.

MQTTReturnCode MQTTSerialize_disconnect ( unsigned char *  buf,
size_t  buflen,
uint32_t *  serialized_length 
)

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer, to avoid overruns
serializedlength
Returns
MQTTReturnCode indicating function execution status

References DISCONNECT, and MQTTSerialize_zero().

size_t MQTTSerialize_GetConnectLength ( MQTTPacket_connectData options)

Determines the length of the MQTT connect packet that would be produced using the supplied connect options.

Parameters
optionsthe options to be used to build the connect packet
thelength of buffer needed to contain the serialized version of the packet
Returns
MQTTReturnCode indicating function execution status

References MQTTPacket_connectData::clientID, MQTTString::cstring, MQTTLenString::data, FUNC_ENTRY, FUNC_EXIT_RC, len, MQTTString::lenstring, MQTTPacket_willOptions::message, MQTTstrlen(), MQTTPacket_connectData::MQTTVersion, MQTTPacket_connectData::password, MQTTPacket_willOptions::topicName, MQTTPacket_connectData::username, MQTTPacket_connectData::will, and MQTTPacket_connectData::willFlag.

Referenced by MQTTSerialize_connect().

MQTTReturnCode MQTTSerialize_pingreq ( unsigned char *  buf,
size_t  buflen,
uint32_t *  serialized_length 
)

Serializes a pingreq packet into the supplied buffer, ready for writing to a socket.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer, to avoid overruns
serializedlength
Returns
MQTTReturnCode indicating function execution status

References MQTTSerialize_zero(), and PINGREQ.

MQTTReturnCode MQTTSerialize_zero ( unsigned char *  buf,
size_t  buflen,
unsigned char  packetType,
uint32_t *  serialized_length 
)

Serializes a 0-length packet into the supplied buffer, ready for writing to a socket.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer, to avoid overruns
packettypethe message type
serializedlength
Returns
MQTTReturnCode indicating function execution status

References buf, MQTTHeader::byte, FUNC_ENTRY, FUNC_EXIT_RC, header, MQTT_NULL_VALUE_ERROR, MQTTPACKET_BUFFER_TOO_SHORT, MQTTPacket_encode(), MQTTPacket_InitHeader(), NULL, ptr, QOS0, SUCCESS, and writeChar().