MQTT C Client Libraries Internals
Functions
MQTTPacketOut.c File Reference

functions to deal with reading and writing of MQTT packets from and to sockets More...

#include "MQTTPacketOut.h"
#include "Log.h"
#include "StackTrace.h"
#include <string.h>
#include <stdlib.h>
#include "Heap.h"
Include dependency graph for MQTTPacketOut.c:

Functions

int MQTTPacket_send_connect (Clients *client, int MQTTVersion, MQTTProperties *connectProperties, MQTTProperties *willProperties)
 Send an MQTT CONNECT packet down a socket for V5 or later. More...
 
void * MQTTPacket_connack (int MQTTVersion, unsigned char aHeader, char *data, size_t datalen)
 Function used in the new packets table to create connack packets. More...
 
void MQTTPacket_freeConnack (Connack *pack)
 Free allocated storage for a connack packet. More...
 
int MQTTPacket_send_pingreq (networkHandles *net, const char *clientID)
 Send an MQTT PINGREQ packet down a socket. More...
 
int MQTTPacket_send_subscribe (List *topics, List *qoss, MQTTSubscribe_options *opts, MQTTProperties *props, int msgid, int dup, Clients *client)
 Send an MQTT subscribe packet down a socket. More...
 
void * MQTTPacket_suback (int MQTTVersion, unsigned char aHeader, char *data, size_t datalen)
 Function used in the new packets table to create suback packets. More...
 
int MQTTPacket_send_unsubscribe (List *topics, MQTTProperties *props, int msgid, int dup, Clients *client)
 Send an MQTT unsubscribe packet down a socket. More...
 
void * MQTTPacket_unsuback (int MQTTVersion, unsigned char aHeader, char *data, size_t datalen)
 Function used in the new packets table to create unsuback packets. More...
 

Detailed Description

functions to deal with reading and writing of MQTT packets from and to sockets

Some other related functions are in the MQTTPacket module

Function Documentation

◆ MQTTPacket_connack()

void* MQTTPacket_connack ( int  MQTTVersion,
unsigned char  aHeader,
char *  data,
size_t  datalen 
)

Function used in the new packets table to create connack packets.

Parameters
MQTTVersionMQTT 5 or less?
aHeaderthe MQTT header byte
datathe rest of the packet
datalenthe length of the rest of the packet
Returns
pointer to the packet structure
Here is the call graph for this function:

◆ MQTTPacket_freeConnack()

void MQTTPacket_freeConnack ( Connack pack)

Free allocated storage for a connack packet.

Parameters
packpointer to the connack packet structure

◆ MQTTPacket_send_connect()

int MQTTPacket_send_connect ( Clients client,
int  MQTTVersion,
MQTTProperties connectProperties,
MQTTProperties willProperties 
)

Send an MQTT CONNECT packet down a socket for V5 or later.

Parameters
clienta structure from which to get all the required values
MQTTVersionthe MQTT version to connect with
connectPropertiesMQTT V5 properties for the connect packet
willPropertiesMQTT V5 properties for the will message, if any
Returns
the completion code (e.g. TCPSOCKET_COMPLETE)
Here is the call graph for this function:

◆ MQTTPacket_send_pingreq()

int MQTTPacket_send_pingreq ( networkHandles net,
const char *  clientID 
)

Send an MQTT PINGREQ packet down a socket.

Parameters
socketthe open socket to send the data to
clientIDthe string client identifier, only used for tracing
Returns
the completion code (e.g. TCPSOCKET_COMPLETE)
Here is the call graph for this function:

◆ MQTTPacket_send_subscribe()

int MQTTPacket_send_subscribe ( List topics,
List qoss,
MQTTSubscribe_options opts,
MQTTProperties props,
int  msgid,
int  dup,
Clients client 
)

Send an MQTT subscribe packet down a socket.

Parameters
topicslist of topics
qosslist of corresponding QoSs
msgidthe MQTT message id to use
dupboolean - whether to set the MQTT DUP flag
socketthe open socket to send the data to
clientIDthe string client identifier, only used for tracing
Returns
the completion code (e.g. TCPSOCKET_COMPLETE)
Here is the call graph for this function:

◆ MQTTPacket_send_unsubscribe()

int MQTTPacket_send_unsubscribe ( List topics,
MQTTProperties props,
int  msgid,
int  dup,
Clients client 
)

Send an MQTT unsubscribe packet down a socket.

Parameters
topicslist of topics
msgidthe MQTT message id to use
dupboolean - whether to set the MQTT DUP flag
socketthe open socket to send the data to
clientIDthe string client identifier, only used for tracing
Returns
the completion code (e.g. TCPSOCKET_COMPLETE)
Here is the call graph for this function:

◆ MQTTPacket_suback()

void* MQTTPacket_suback ( int  MQTTVersion,
unsigned char  aHeader,
char *  data,
size_t  datalen 
)

Function used in the new packets table to create suback packets.

Parameters
MQTTVersionthe version of MQTT
aHeaderthe MQTT header byte
datathe rest of the packet
datalenthe length of the rest of the packet
Returns
pointer to the packet structure
Here is the call graph for this function:

◆ MQTTPacket_unsuback()

void* MQTTPacket_unsuback ( int  MQTTVersion,
unsigned char  aHeader,
char *  data,
size_t  datalen 
)

Function used in the new packets table to create unsuback packets.

Parameters
MQTTVersionthe version of MQTT
aHeaderthe MQTT header byte
datathe rest of the packet
datalenthe length of the rest of the packet
Returns
pointer to the packet structure
Here is the call graph for this function: