Microchip® Advanced Software Framework

MQTTConnectServer.c File Reference
#include "StackTrace.h"
#include "MQTTPacket.h"
#include <string.h>

Macros

#define min(a, b)   ((a < b) ? a : b)
 

Functions

int MQTTDeserialize_connect (MQTTPacket_connectData *data, unsigned char *buf, int len)
 Deserializes the supplied (wire) buffer into connect data structure. More...
 
int MQTTPacket_checkVersion (MQTTString *protocol, int version)
 Validates MQTT protocol name and version combinations. More...
 
int MQTTSerialize_connack (unsigned char *buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
 Serializes the connack packet into the supplied buffer. More...
 

#define min (   a,
 
)    ((a < b) ? a : b)

Referenced by MQTTPacket_checkVersion().

int MQTTPacket_checkVersion ( MQTTString protocol,
int  version 
)

Validates MQTT protocol name and version combinations.

Parameters
protocolthe MQTT protocol name as an MQTTString
versionthe MQTT protocol version number, as in the connect packet
Returns
correct MQTT combination? 1 is true, 0 is false

References MQTTLenString::data, MQTTLenString::len, MQTTString::lenstring, and min.

Referenced by MQTTDeserialize_connect().

int MQTTSerialize_connack ( unsigned char *  buf,
int  buflen,
unsigned char  connack_rc,
unsigned char  sessionPresent 
)

Serializes the connack packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
connack_rcthe integer connack return code to be used
sessionPresentthe MQTT 3.1.1 sessionPresent flag
Returns
serialized length, or error if 0

References MQTTConnackFlags::all, MQTTHeader::bits, MQTTConnackFlags::bits, buf, MQTTHeader::byte, CONNACK, FUNC_ENTRY, FUNC_EXIT_RC, header, MQTTPACKET_BUFFER_TOO_SHORT, MQTTPacket_encode(), ptr, MQTTConnackFlags::sessionpresent, MQTTHeader::type, and writeChar().