Macros | |
#define | MAX_NO_OF_REMAINING_LENGTH_BYTES 4 |
Functions | |
int | bufchar (unsigned char *c, int count) |
int | getLenStringLen (char *ptr) |
int | MQTTPacket_decode (int(*getcharfn)(unsigned char *, int), int *value) |
Decodes the message length according to the MQTT algorithm. More... | |
int | MQTTPacket_decodeBuf (unsigned char *buf, int *value) |
static int | MQTTPacket_decodenb (MQTTTransport *trp) |
Decodes the message length according to the MQTT algorithm, non-blocking. More... | |
int | MQTTPacket_encode (unsigned char *buf, int length) |
Encodes the message length according to the MQTT algorithm. More... | |
int | MQTTPacket_equals (MQTTString *a, char *bptr) |
Compares an MQTTString to a C string. More... | |
int | MQTTPacket_len (int rem_len) |
int | MQTTPacket_read (unsigned char *buf, int buflen, int(*getfn)(unsigned char *, int)) |
Helper function to read packet data from some source into a buffer. More... | |
int | MQTTPacket_readnb (unsigned char *buf, int buflen, MQTTTransport *trp) |
Helper function to read packet data from some source into a buffer, non-blocking. More... | |
int | MQTTstrlen (MQTTString mqttstring) |
Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string. More... | |
char | readChar (unsigned char **pptr) |
Reads one character from the input buffer. More... | |
int | readInt (unsigned char **pptr) |
Calculates an integer from two bytes read from the input buffer. More... | |
int | readMQTTLenString (MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata) |
void | writeChar (unsigned char **pptr, char c) |
Writes one character to an output buffer. More... | |
void | writeCString (unsigned char **pptr, const char *string) |
Writes a "UTF" string to an output buffer. More... | |
void | writeInt (unsigned char **pptr, int anInt) |
Writes an integer as 2 bytes to an output buffer. More... | |
void | writeMQTTString (unsigned char **pptr, MQTTString mqttstring) |
Variables | |
static unsigned char * | bufptr |
#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4 |
Referenced by decodePacket(), MQTTPacket_decode(), and MQTTPacket_decodenb().
int bufchar | ( | unsigned char * | c, |
int | count | ||
) |
Referenced by MQTTPacket_decodeBuf().
int getLenStringLen | ( | char * | ptr | ) |
int MQTTPacket_decode | ( | int(*)(unsigned char *, int) | getcharfn, |
int * | value | ||
) |
Decodes the message length according to the MQTT algorithm.
getcharfn | pointer to function to read the next character from the data source |
value | the decoded length returned |
References FUNC_ENTRY, FUNC_EXIT_RC, MAX_NO_OF_REMAINING_LENGTH_BYTES, and MQTTPACKET_READ_ERROR.
Referenced by MQTTPacket_decodeBuf(), and MQTTPacket_read().
int MQTTPacket_decodeBuf | ( | unsigned char * | buf, |
int * | value | ||
) |
References bufchar(), and MQTTPacket_decode().
Referenced by MQTTDeserialize_ack(), MQTTDeserialize_connack(), MQTTDeserialize_connect(), MQTTDeserialize_publish(), MQTTDeserialize_suback(), MQTTDeserialize_subscribe(), MQTTDeserialize_unsubscribe(), MQTTFormat_toClientString(), and MQTTFormat_toServerString().
|
static |
Decodes the message length according to the MQTT algorithm, non-blocking.
trp | pointer to a transport structure holding what is needed to solve getting data from it |
value | the decoded length returned |
References FUNC_ENTRY, FUNC_EXIT_RC, MQTTTransport::getfn, MQTTTransport::len, MAX_NO_OF_REMAINING_LENGTH_BYTES, MQTTPACKET_READ_ERROR, MQTTTransport::multiplier, MQTTTransport::rem_len, and MQTTTransport::sck.
Referenced by MQTTPacket_readnb().
int MQTTPacket_encode | ( | unsigned char * | buf, |
int | length | ||
) |
Encodes the message length according to the MQTT algorithm.
buf | the buffer into which the encoded data is written |
length | the length to be encoded |
References FUNC_ENTRY, and FUNC_EXIT_RC.
Referenced by MQTTPacket_read(), MQTTPacket_readnb(), MQTTSerialize_ack(), MQTTSerialize_connack(), MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_suback(), MQTTSerialize_subscribe(), MQTTSerialize_unsuback(), MQTTSerialize_unsubscribe(), MQTTSerialize_zero(), and readPacket().
int MQTTPacket_equals | ( | MQTTString * | a, |
char * | bptr | ||
) |
Compares an MQTTString to a C string.
a | the MQTTString to compare |
bptr | the C string to compare |
References MQTTString::cstring, MQTTLenString::data, MQTTLenString::len, and MQTTString::lenstring.
Referenced by deliverMessage().
int MQTTPacket_len | ( | int | rem_len | ) |
Referenced by MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_subscribe(), and MQTTSerialize_unsubscribe().
int MQTTPacket_read | ( | unsigned char * | buf, |
int | buflen, | ||
int(*)(unsigned char *, int) | getfn | ||
) |
Helper function to read packet data from some source into a buffer.
buf | the buffer into which the packet will be serialized |
buflen | the length in bytes of the supplied buffer |
getfn | pointer to a function which will read any number of bytes from the needed source |
References MQTTHeader::bits, MQTTHeader::byte, header, MQTTPacket_decode(), MQTTPacket_encode(), and MQTTHeader::type.
int MQTTPacket_readnb | ( | unsigned char * | buf, |
int | buflen, | ||
MQTTTransport * | trp | ||
) |
Helper function to read packet data from some source into a buffer, non-blocking.
buf | the buffer into which the packet will be serialized |
buflen | the length in bytes of the supplied buffer |
trp | pointer to a transport structure holding what is needed to solve getting data from it |
References MQTTHeader::bits, MQTTHeader::byte, MQTTTransport::getfn, header, MQTTTransport::len, MQTTPacket_decodenb(), MQTTPacket_encode(), MQTTPACKET_READ_ERROR, MQTTTransport::rem_len, MQTTTransport::sck, MQTTTransport::state, and MQTTHeader::type.
int MQTTstrlen | ( | MQTTString | mqttstring | ) |
Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string.
mqttstring | the string to return the length of |
References MQTTString::cstring, MQTTLenString::len, and MQTTString::lenstring.
Referenced by MQTTSerialize_connectLength(), MQTTSerialize_publishLength(), MQTTSerialize_subscribeLength(), and MQTTSerialize_unsubscribeLength().
char readChar | ( | unsigned char ** | pptr | ) |
Reads one character from the input buffer.
pptr | pointer to the input buffer - incremented by the number of bytes used & returned |
Referenced by MQTTDeserialize_ack(), MQTTDeserialize_connack(), MQTTDeserialize_connect(), MQTTDeserialize_publish(), MQTTDeserialize_suback(), MQTTDeserialize_subscribe(), and MQTTDeserialize_unsubscribe().
int readInt | ( | unsigned char ** | pptr | ) |
Calculates an integer from two bytes read from the input buffer.
pptr | pointer to the input buffer - incremented by the number of bytes used & returned |
References ptr.
Referenced by MQTTDeserialize_ack(), MQTTDeserialize_connect(), MQTTDeserialize_publish(), MQTTDeserialize_suback(), MQTTDeserialize_subscribe(), MQTTDeserialize_unsubscribe(), and readMQTTLenString().
int readMQTTLenString | ( | MQTTString * | mqttstring, |
unsigned char ** | pptr, | ||
unsigned char * | enddata | ||
) |
mqttstring | the MQTTString structure into which the data is to be read |
pptr | pointer to the output buffer - incremented by the number of bytes used & returned |
enddata | pointer to the end of the data: do not read beyond |
References MQTTString::cstring, MQTTLenString::data, FUNC_ENTRY, FUNC_EXIT_RC, MQTTLenString::len, MQTTString::lenstring, NULL, and readInt().
Referenced by MQTTDeserialize_connect(), MQTTDeserialize_publish(), MQTTDeserialize_subscribe(), and MQTTDeserialize_unsubscribe().
void writeChar | ( | unsigned char ** | pptr, |
char | c | ||
) |
Writes one character to an output buffer.
pptr | pointer to the output buffer - incremented by the number of bytes used & returned |
c | the character to write |
Referenced by MQTTSerialize_ack(), MQTTSerialize_connack(), MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_suback(), MQTTSerialize_subscribe(), MQTTSerialize_unsuback(), MQTTSerialize_unsubscribe(), and MQTTSerialize_zero().
void writeCString | ( | unsigned char ** | pptr, |
const char * | string | ||
) |
Writes a "UTF" string to an output buffer.
Converts C string to length-delimited.
pptr | pointer to the output buffer - incremented by the number of bytes used & returned |
string | the C string to write |
References writeInt().
Referenced by MQTTSerialize_connect(), and writeMQTTString().
void writeInt | ( | unsigned char ** | pptr, |
int | anInt | ||
) |
Writes an integer as 2 bytes to an output buffer.
pptr | pointer to the output buffer - incremented by the number of bytes used & returned |
anInt | the integer to write |
Referenced by MQTTSerialize_ack(), MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_suback(), MQTTSerialize_subscribe(), MQTTSerialize_unsuback(), MQTTSerialize_unsubscribe(), writeCString(), and writeMQTTString().
void writeMQTTString | ( | unsigned char ** | pptr, |
MQTTString | mqttstring | ||
) |
References MQTTString::cstring, MQTTLenString::data, MQTTLenString::len, MQTTString::lenstring, writeCString(), and writeInt().
Referenced by MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_subscribe(), and MQTTSerialize_unsubscribe().
|
static |