Functions dealing with the MQTT protocol exchanges. More...
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "MQTTProtocolClient.h"
#include "MQTTPersistence.h"
#include "SocketBuffer.h"
#include "StackTrace.h"
#include "Heap.h"
Go to the source code of this file.
Macros | |
#define | min(A, B) ( (A) < (B) ? (A):(B)) |
Variables | |
ClientStates * | bstate |
MQTTProtocol | state |
Functions dealing with the MQTT protocol exchanges.
Some other related functions are in the MQTTProtocolOut module
Definition in file MQTTProtocolClient.c.
#define min | ( | A, | |
B | |||
) | ( (A) < (B) ? (A):(B)) |
Definition at line 44 of file MQTTProtocolClient.c.
int messageIDCompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing Message structures by message id
a | first integer value |
b | second integer value |
Definition at line 65 of file MQTTProtocolClient.c.
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 |
Definition at line 78 of file MQTTProtocolClient.c.
Messages* MQTTProtocol_createMessage | ( | Publish * | publish, |
Messages ** | mm, | ||
int | qos, | ||
int | retained, | ||
int | allocatePayload | ||
) |
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 |
allocatePayload | boolean - whether or not to malloc payload |
Definition at line 196 of file MQTTProtocolClient.c.
void MQTTProtocol_emptyMessageList | ( | List * | msgList | ) |
Empty a message list, leaving it able to accept new messages
msgList | the message list to empty |
Definition at line 862 of file MQTTProtocolClient.c.
void MQTTProtocol_freeClient | ( | Clients * | client | ) |
Free a client structure
client | the client data to free |
Definition at line 811 of file MQTTProtocolClient.c.
void MQTTProtocol_freeMessageList | ( | List * | msgList | ) |
Empty and free up all storage used by a message list
msgList | the message list to empty and free |
Definition at line 883 of file MQTTProtocolClient.c.
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 |
Definition at line 407 of file MQTTProtocolClient.c.
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 |
Definition at line 601 of file MQTTProtocolClient.c.
int MQTTProtocol_handlePublishes | ( | void * | pack, |
int | sock | ||
) |
Process an incoming publish packet for a socket The payload field of the packet has not been transferred to another buffer at this point. If it's needed beyond the scope of this function, it has to be copied.
pack | pointer to the publish packet |
sock | the socket on which the packet was received |
Definition at line 305 of file MQTTProtocolClient.c.
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 |
Definition at line 453 of file MQTTProtocolClient.c.
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 |
Definition at line 522 of file MQTTProtocolClient.c.
void MQTTProtocol_keepalive | ( | START_TIME_TYPE | now | ) |
MQTT protocol keepAlive processing. Sends PINGREQ packets as required.
now | current time |
Definition at line 656 of file MQTTProtocolClient.c.
void MQTTProtocol_removePublication | ( | Publications * | p | ) |
Remove stored message data. Opposite of storePublication
p | stored publication to remove |
Definition at line 285 of file MQTTProtocolClient.c.
|
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) |
Definition at line 706 of file MQTTProtocolClient.c.
void MQTTProtocol_retry | ( | START_TIME_TYPE | 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) |
Definition at line 780 of file MQTTProtocolClient.c.
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 |
Definition at line 162 of file MQTTProtocolClient.c.
|
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 |
Definition at line 140 of file MQTTProtocolClient.c.
Publications* MQTTProtocol_storePublication | ( | Publish * | publish, |
int * | len | ||
) |
Store message data for possible retry
publish | the publication data |
len | returned length of the data stored |
Definition at line 252 of file MQTTProtocolClient.c.
Definition at line 101 of file MQTTProtocolClient.c.
char* MQTTStrdup | ( | const char * | src | ) |
Duplicate a string, safely, allocating space on the heap
src | the source string which characters copy from |
Definition at line 925 of file MQTTProtocolClient.c.
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 |
Definition at line 900 of file MQTTProtocolClient.c.
ClientStates* bstate |
Definition at line 117 of file MQTTAsync.c.
MQTTProtocol state |