![]() |
MQTT C Client Libraries Internals
|
Functions dealing with the MQTT protocol exchanges. More...
#include <stdlib.h>
#include <string.h>
#include "MQTTProtocolClient.h"
#include "MQTTPersistence.h"
#include "SocketBuffer.h"
#include "StackTrace.h"
#include "Heap.h"
Macros | |
#define | min(A, B) ( (A) < (B) ? (A):(B)) |
Functions | |
static void | MQTTProtocol_storeQoS0 (Clients *pubclient, Publish *publish) |
static int | MQTTProtocol_startPublishCommon (Clients *pubclient, Publish *publish, int qos, int retained) |
Utility function to start a new publish exchange. More... | |
static void | MQTTProtocol_retries (time_t now, Clients *client, int regardless) |
MQTT retry processing per client. More... | |
int | messageIDCompare (void *a, void *b) |
List callback function for comparing Message structures by message id. More... | |
int | MQTTProtocol_assignMsgId (Clients *client) |
Assign a new message id for a client. More... | |
int | MQTTProtocol_startPublish (Clients *pubclient, Publish *publish, int qos, int retained, Messages **mm) |
Start a new publish exchange. More... | |
Messages * | MQTTProtocol_createMessage (Publish *publish, Messages **mm, int qos, int retained) |
Copy and store message data for retries. More... | |
Publications * | MQTTProtocol_storePublication (Publish *publish, int *len) |
Store message data for possible retry. More... | |
void | MQTTProtocol_removePublication (Publications *p) |
Remove stored message data. More... | |
int | MQTTProtocol_handlePublishes (void *pack, int sock) |
Process an incoming publish packet for a socket. More... | |
int | MQTTProtocol_handlePubacks (void *pack, int sock) |
Process an incoming puback packet for a socket. More... | |
int | MQTTProtocol_handlePubrecs (void *pack, int sock) |
Process an incoming pubrec packet for a socket. More... | |
int | MQTTProtocol_handlePubrels (void *pack, int sock) |
Process an incoming pubrel packet for a socket. More... | |
int | MQTTProtocol_handlePubcomps (void *pack, int sock) |
Process an incoming pubcomp packet for a socket. More... | |
void | MQTTProtocol_keepalive (time_t now) |
MQTT protocol keepAlive processing. More... | |
void | MQTTProtocol_retry (time_t now, int doRetry, int regardless) |
MQTT retry protocol and socket pending writes processing. More... | |
void | MQTTProtocol_freeClient (Clients *client) |
Free a client structure. More... | |
void | MQTTProtocol_emptyMessageList (List *msgList) |
Empty a message list, leaving it able to accept new messages. More... | |
void | MQTTProtocol_freeMessageList (List *msgList) |
Empty and free up all storage used by a message list. More... | |
char * | MQTTStrncpy (char *dest, const char *src, size_t dest_size) |
Copy no more than dest_size -1 characters from the string pointed to by src to the array pointed to by dest. More... | |
char * | MQTTStrdup (const char *src) |
Duplicate a string, safely, allocating space on the heap. More... | |
Variables | |
MQTTProtocol | state |
ClientStates * | bstate |
Functions dealing with the MQTT protocol exchanges.
Some other related functions are in the MQTTProtocolOut module
int messageIDCompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing Message structures by message id.
a | first integer value |
b | second integer value |
int MQTTProtocol_assignMsgId | ( | Clients * | client | ) |
Assign a new message id for a client.
Make sure it isn't already being used and does not exceed the maximum.
client | a client structure |
Copy and store message data for retries.
publish | the publication data |
mm | - pointer to the message data to store |
qos | the MQTT QoS to use |
retained | boolean - whether to set the MQTT retained flag |
void MQTTProtocol_emptyMessageList | ( | List * | msgList | ) |
Empty a message list, leaving it able to accept new messages.
msgList | the message list to empty |
void MQTTProtocol_freeClient | ( | Clients * | client | ) |
Free a client structure.
client | the client data to free |
void MQTTProtocol_freeMessageList | ( | List * | msgList | ) |
Empty and free up all storage used by a message list.
msgList | the message list to empty and free |
int MQTTProtocol_handlePubacks | ( | void * | pack, |
int | sock | ||
) |
Process an incoming puback packet for a socket.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
int MQTTProtocol_handlePubcomps | ( | void * | pack, |
int | sock | ||
) |
Process an incoming pubcomp packet for a socket.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
int MQTTProtocol_handlePublishes | ( | void * | pack, |
int | sock | ||
) |
Process an incoming publish packet for a socket.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
int MQTTProtocol_handlePubrecs | ( | void * | pack, |
int | sock | ||
) |
Process an incoming pubrec packet for a socket.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
int MQTTProtocol_handlePubrels | ( | void * | pack, |
int | sock | ||
) |
Process an incoming pubrel packet for a socket.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
void MQTTProtocol_keepalive | ( | time_t | now | ) |
MQTT protocol keepAlive processing.
Sends PINGREQ packets as required.
now | current time |
void MQTTProtocol_removePublication | ( | Publications * | p | ) |
Remove stored message data.
Opposite of storePublication
p | stored publication to remove |
|
static |
MQTT retry processing per client.
now | current time |
client | - the client to which to apply the retry processing |
regardless | boolean - retry packets regardless of retry interval (used on reconnect) |
void MQTTProtocol_retry | ( | time_t | now, |
int | doRetry, | ||
int | regardless | ||
) |
MQTT retry protocol and socket pending writes processing.
now | current time |
doRetry | boolean - retries as well as pending writes? |
regardless | boolean - retry packets regardless of retry interval (used on reconnect) |
int MQTTProtocol_startPublish | ( | Clients * | pubclient, |
Publish * | publish, | ||
int | qos, | ||
int | retained, | ||
Messages ** | mm | ||
) |
Start a new publish exchange.
Store any state necessary and try to send the packet
pubclient | the client to send the publication to |
publish | the publication data |
qos | the MQTT QoS to use |
retained | boolean - whether to set the MQTT retained flag |
mm | - pointer to the message to send |
|
static |
Utility function to start a new publish exchange.
pubclient | the client to send the publication to |
publish | the publication data |
qos | the MQTT QoS to use |
retained | boolean - whether to set the MQTT retained flag |
Publications* MQTTProtocol_storePublication | ( | Publish * | publish, |
int * | len | ||
) |
Store message data for possible retry.
publish | the publication data |
len | returned length of the data stored |
char* MQTTStrdup | ( | const char * | src | ) |
Duplicate a string, safely, allocating space on the heap.
src | the source string which characters copy from |
char* MQTTStrncpy | ( | char * | dest, |
const char * | src, | ||
size_t | dest_size | ||
) |
Copy no more than dest_size -1 characters from the string pointed to by src to the array pointed to by dest.
The destination string will always be null-terminated.
dest | the array which characters copy to |
src | the source string which characters copy from |
dest_size | the size of the memory pointed to by dest: copy no more than this -1 (allow for null). Must be >= 1 |