Macros | |
#define | MAX_NO_OF_REMAINING_LENGTH_BYTES 4 |
Functions | |
uint32_t | bufchar (unsigned char *c, uint32_t count) |
MQTTReturnCode | MQTTPacket_decode (uint32_t(*getcharfn)(unsigned char *, uint32_t), uint32_t *value, uint32_t *readBytesLen) |
Decodes the message length according to the MQTT algorithm. More... | |
MQTTReturnCode | MQTTPacket_decodeBuf (unsigned char *buf, uint32_t *value, uint32_t *readBytesLen) |
uint32_t | MQTTPacket_encode (unsigned char *buf, size_t length) |
Encodes the message length according to the MQTT algorithm. More... | |
uint8_t | MQTTPacket_equals (MQTTString *a, char *bptr) |
Compares an MQTTString to a C string. More... | |
MQTTReturnCode | MQTTPacket_InitHeader (MQTTHeader *header, MessageTypes message_type, QoS qos, uint8_t dup, uint8_t retained) |
Initialize the MQTTHeader structure. More... | |
size_t | MQTTPacket_len (size_t rem_len) |
size_t | MQTTstrlen (MQTTString mqttstring) |
Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string. More... | |
unsigned char | readChar (unsigned char **pptr) |
Reads one character from the input buffer. More... | |
int32_t | readInt (unsigned char **pptr) |
Calculates an integer from two bytes read from the input buffer. More... | |
MQTTReturnCode | readMQTTLenString (MQTTString *mqttstring, unsigned char **pptr, unsigned char *enddata) |
uint16_t | readPacketId (unsigned char **pptr) |
Calculates uint16 packet id from two bytes read from the input buffer. More... | |
size_t | readSizeT (unsigned char **pptr) |
Calculates an integer from two bytes read from the input buffer. More... | |
void | writeChar (unsigned char **pptr, unsigned 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, int32_t anInt) |
Writes an integer as 2 bytes to an output buffer. More... | |
void | writeMQTTString (unsigned char **pptr, MQTTString mqttstring) |
void | writePacketId (unsigned char **pptr, uint16_t anInt) |
Writes an integer as 2 bytes to an output buffer. More... | |
void | writeSizeT (unsigned char **pptr, size_t size) |
Writes size as 2 bytes to an output buffer. More... | |
Variables | |
static unsigned char * | bufptr |
#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4 |
Referenced by MQTTPacket_decode().
MQTTReturnCode MQTTPacket_decode | ( | uint32_t(*)(unsigned char *, uint32_t) | getcharfn, |
uint32_t * | value, | ||
uint32_t * | readBytesLen | ||
) |
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 c, FAILURE, FUNC_ENTRY, FUNC_EXIT_RC, len, MAX_NO_OF_REMAINING_LENGTH_BYTES, MQTTPACKET_READ_ERROR, and SUCCESS.
MQTTReturnCode MQTTPacket_decodeBuf | ( | unsigned char * | buf, |
uint32_t * | value, | ||
uint32_t * | readBytesLen | ||
) |
References buf, bufchar(), and MQTTPacket_decode().
uint32_t MQTTPacket_encode | ( | unsigned char * | buf, |
size_t | 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.
uint8_t 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.
MQTTReturnCode MQTTPacket_InitHeader | ( | MQTTHeader * | header, |
MessageTypes | message_type, | ||
QoS | qos, | ||
uint8_t | dup, | ||
uint8_t | retained | ||
) |
Initialize the MQTTHeader structure.
Used to ensure that Header bits are always initialized using the proper mappings. No Endianness issues here since the individual fields are all less than a byte. Also generates no warnings since all fields are initialized using hex constants
References MQTTHeader::bits, MQTTHeader::byte, CONNACK, CONNECT, DISCONNECT, MQTTHeader::dup, MQTT_NULL_VALUE_ERROR, MQTT_UNKNOWN_ERROR, NULL, PINGREQ, PINGRESP, PUBACK, PUBCOMP, PUBLISH, PUBREC, PUBREL, MQTTHeader::qos, QOS0, QOS1, QOS2, MQTTHeader::retain, SUBACK, SUBSCRIBE, SUCCESS, MQTTHeader::type, UNKNOWN, UNSUBACK, and UNSUBSCRIBE.
Referenced by MQTTSerialize_ack(), MQTTSerialize_connect(), MQTTSerialize_publish(), MQTTSerialize_subscribe(), MQTTSerialize_unsubscribe(), and MQTTSerialize_zero().
size_t MQTTPacket_len | ( | size_t | rem_len | ) |
size_t 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, len, and MQTTString::lenstring.
unsigned 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 |
References c.
int32_t readInt | ( | unsigned char ** | pptr | ) |
MQTTReturnCode 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, FAILURE, FUNC_ENTRY, FUNC_EXIT_RC, MQTTLenString::len, MQTTString::lenstring, NULL, readInt(), readSizeT(), and SUCCESS.
uint16_t readPacketId | ( | unsigned char ** | pptr | ) |
Calculates uint16 packet id from two bytes read from the input buffer.
pptr | pointer to the input buffer - incremented by the number of bytes used & returned |
Referenced by MQTTDeserialize_ack(), MQTTDeserialize_publish(), and MQTTDeserialize_suback().
size_t readSizeT | ( | 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 readMQTTLenString().
void writeChar | ( | unsigned char ** | pptr, |
unsigned 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 |
References c.
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 len, writeInt(), and writeSizeT().
void writeInt | ( | unsigned char ** | pptr, |
int32_t | 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 |
void writeMQTTString | ( | unsigned char ** | pptr, |
MQTTString | mqttstring | ||
) |
void writePacketId | ( | unsigned char ** | pptr, |
uint16_t | 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_subscribe(), and MQTTSerialize_unsubscribe().
void writeSizeT | ( | unsigned char ** | pptr, |
size_t | size | ||
) |
Writes size 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 writeCString(), and writeMQTTString().
|
static |