API  2.2
TSmarT Software Library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions

Functions

int MQTTSerialize_connectLength (MQTTPacket_connectData *options)
 
int MQTTSerialize_connect (char *buf, int buflen, MQTTPacket_connectData *options)
 
int MQTTDeserialize_connack (int *connack_rc, char *buf, int buflen)
 
int MQTTSerialize_disconnect (char *buf, int buflen)
 
int MQTTPacket_checkVersion (MQTTString *protocol, int version)
 
int MQTTDeserialize_connect (MQTTPacket_connectData *data, char *buf, int len)
 
int MQTTSerialize_connack (char *buf, int buflen, int connack_rc)
 
int MQTTDeserialize_publish (int *dup, int *qos, int *retained, int *packetid, MQTTString *topicName, char **payload, int *payloadlen, char *buf, int buflen)
 
int MQTTDeserialize_ack (int *type, int *dup, int *packetid, char *buf, int buflen)
 
int MQTTPacket_encode (char *buf, int length)
 
int MQTTPacket_decode (int(*getcharfn)(char *, int), int *value)
 
int readInt (char **pptr)
 
char readChar (char **pptr)
 
void writeChar (char **pptr, char c)
 
void writeInt (char **pptr, int anInt)
 
void writeCString (char **pptr, char *string)
 
int readMQTTLenString (MQTTString *mqttstring, char **pptr, char *enddata)
 
int MQTTstrlen (MQTTString mqttstring)
 
int MQTTPacket_read (char *buf, int buflen, int(*getfn)(char *, int))
 
int MQTTSerialize_publishLength (int qos, MQTTString topicName, int payloadlen)
 
int MQTTSerialize_publish (char *buf, int buflen, int dup, int qos, int retained, int packetid, MQTTString topicName, char *payload, int payloadlen)
 
int MQTTSerialize_ack (char *buf, int buflen, int type, int dup, int packetid)
 
int MQTTSerialize_puback (char *buf, int buflen, int packetid)
 
int MQTTSerialize_pubrel (char *buf, int buflen, int dup, int packetid)
 
int MQTTSerialize_pubcomp (char *buf, int buflen, int packetid)
 
int MQTTSerialize_subscribeLength (int count, MQTTString topicFilters[])
 
int MQTTSerialize_subscribe (char *buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[], int requestedQoSs[])
 
int MQTTDeserialize_suback (int *packetid, int maxcount, int *count, int grantedQoSs[], char *buf, int buflen)
 
int MQTTDeserialize_subscribe (int *dup, int *packetid, int maxcount, int *count, MQTTString topicFilters[], int requestedQoSs[], char *buf, int buflen)
 
int MQTTSerialize_suback (char *buf, int buflen, int packetid, int count, int *grantedQoSs)
 
int MQTTSerialize_unsubscribeLength (int count, MQTTString topicFilters[])
 
int MQTTSerialize_unsubscribe (char *buf, int buflen, int dup, int packetid, int count, MQTTString topicFilters[])
 
int MQTTDeserialize_unsuback (int *packetid, char *buf, int buflen)
 
int MQTTDeserialize_unsubscribe (int *dup, int *packetid, int maxcount, int *count, MQTTString topicFilters[], char *buf, int len)
 
int MQTTSerialize_unsuback (char *buf, int buflen, int packetid)
 

Detailed Description

Function Documentation

int MQTTDeserialize_ack ( int *  type,
int *  dup,
int *  packetid,
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into an ack

Parameters
typereturned integer - the MQTT packet type
dupreturned integer - the MQTT dup flag
packetidreturned integer - the MQTT packet identifier
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure
int MQTTDeserialize_connack ( int *  connack_rc,
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into connack data - return code

Parameters
connack_rcreturned integer value of the connack return code
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure
int MQTTDeserialize_connect ( MQTTPacket_connectData *  data,
char *  buf,
int  len 
)

Deserializes the supplied (wire) buffer into connect data structure

Parameters
datathe connect data structure to be filled out
bufthe raw buffer data, of the correct length determined by the remaining length field
lenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure
int MQTTDeserialize_publish ( int *  dup,
int *  qos,
int *  retained,
int *  packetid,
MQTTString *  topicName,
char **  payload,
int *  payloadlen,
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into publish data

Parameters
dupreturned integer - the MQTT dup flag
qosreturned integer - the MQTT QoS value
retainedreturned integer - the MQTT retained flag
packetidreturned integer - the MQTT packet identifier
topicNamereturned MQTTString - the MQTT topic in the publish
payloadreturned byte buffer - the MQTT publish payload
payloadlenreturned integer - the length of the MQTT payload
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success
int MQTTDeserialize_suback ( int *  packetid,
int  maxcount,
int *  count,
int  grantedQoSs[],
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into suback data

Parameters
packetidreturned integer - the MQTT packet identifier
maxcount- the maximum number of members allowed in the grantedQoSs array
countreturned integer - number of members in the grantedQoSs array
grantedQoSsreturned array of integers - the granted qualities of service
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure
int MQTTDeserialize_subscribe ( int *  dup,
int *  packetid,
int  maxcount,
int *  count,
MQTTString  topicFilters[],
int  requestedQoSs[],
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into subscribe data

Parameters
dupinteger returned - the MQTT dup flag
packetidinteger returned - the MQTT packet identifier
maxcount- the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count- number of members in the topicFilters and requestedQoSs arrays
topicFilters- array of topic filter names
requestedQoSs- array of requested QoS
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error
int MQTTDeserialize_unsuback ( int *  packetid,
char *  buf,
int  buflen 
)

Deserializes the supplied (wire) buffer into unsuback data

Parameters
packetidreturned integer - the MQTT packet identifier
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
Returns
error code. 1 is success, 0 is failure
int MQTTDeserialize_unsubscribe ( int *  dup,
int *  packetid,
int  maxcount,
int *  count,
MQTTString  topicFilters[],
char *  buf,
int  len 
)

Deserializes the supplied (wire) buffer into unsubscribe data

Parameters
dupinteger returned - the MQTT dup flag
packetidinteger returned - the MQTT packet identifier
maxcount- the maximum number of members allowed in the topicFilters and requestedQoSs arrays
count- number of members in the topicFilters and requestedQoSs arrays
topicFilters- array of topic filter names
bufthe raw buffer data, of the correct length determined by the remaining length field
lenthe length in bytes of the data in the supplied buffer
Returns
the length of the serialized data. <= 0 indicates error
int MQTTPacket_checkVersion ( MQTTString *  protocol,
int  version 
)

Validates MQTT protocol name and version combinations

Parameters
protocolthe MQTT protocol name as an MQTTString
versionthe MQTT protocol version number, as in the connect packet
Returns
correct MQTT combination? 1 is true, 0 is false
int MQTTPacket_decode ( int(*)(char *, int)  getcharfn,
int *  value 
)

Decodes the message length according to the MQTT algorithm

Parameters
getcharfnpointer to function to read the next character from the data source
valuethe decoded length returned
Returns
the number of bytes read from the socket
int MQTTPacket_encode ( char *  buf,
int  length 
)

Encodes the message length according to the MQTT algorithm

Parameters
bufthe buffer into which the encoded data is written
lengththe length to be encoded
Returns
the number of bytes written to buffer
int MQTTPacket_read ( char *  buf,
int  buflen,
int(*)(char *, int)  getfn 
)

Helper function to read packet data from some source into a buffer

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
getfnpointer to a function which will read any number of bytes from the needed source
Returns
integer MQTT packet type, or -1 on error
int MQTTSerialize_ack ( char *  buf,
int  buflen,
int  type,
int  dup,
int  packetid 
)

Serializes the ack packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
typeinteger - the MQTT packet type
dupinteger - the MQTT dup flag
packetidinteger - the MQTT packet identifier
Returns
serialized length, or error if 0
int MQTTSerialize_connack ( char *  buf,
int  buflen,
int  connack_rc 
)

Serializes the connack packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
connack_rcthe integer connack return code to be used
Returns
serialized length, or error if 0
int MQTTSerialize_connect ( char *  buf,
int  buflen,
MQTTPacket_connectData *  options 
)

Serializes the connect options into the buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
optionsthe options to be used to build the connect packet
Returns
serialized length, or error if 0
int MQTTSerialize_connectLength ( MQTTPacket_connectData *  options)

Determines the length of the MQTT connect packet that would be produced using the supplied connect options.

Parameters
optionsthe options to be used to build the connect packet
Returns
the length of buffer needed to contain the serialized version of the packet
int MQTTSerialize_disconnect ( char *  buf,
int  buflen 
)

Serializes a disconnect packet into the supplied buffer, ready for writing to a socket

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer, to avoid overruns
Returns
serialized length, or error if 0
int MQTTSerialize_puback ( char *  buf,
int  buflen,
int  packetid 
)

Serializes a puback packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
packetidinteger - the MQTT packet identifier
Returns
serialized length, or error if 0
int MQTTSerialize_pubcomp ( char *  buf,
int  buflen,
int  packetid 
)

Serializes a pubrel packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
packetidinteger - the MQTT packet identifier
Returns
serialized length, or error if 0
int MQTTSerialize_publish ( char *  buf,
int  buflen,
int  dup,
int  qos,
int  retained,
int  packetid,
MQTTString  topicName,
char *  payload,
int  payloadlen 
)

Serializes the supplied publish data into the supplied buffer, ready for sending

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
dupinteger - the MQTT dup flag
qosinteger - the MQTT QoS value
retainedinteger - the MQTT retained flag
packetidinteger - the MQTT packet identifier
topicNameMQTTString - the MQTT topic in the publish
payloadbyte buffer - the MQTT publish payload
payloadleninteger - the length of the MQTT payload
Returns
the length of the serialized data. <= 0 indicates error
int MQTTSerialize_publishLength ( int  qos,
MQTTString  topicName,
int  payloadlen 
)

Determines the length of the MQTT publish packet that would be produced using the supplied parameters

Parameters
qosthe MQTT QoS of the publish (packetid is omitted for QoS 0)
topicNamethe topic name to be used in the publish
payloadlenthe length of the payload to be sent
Returns
the length of buffer needed to contain the serialized version of the packet
int MQTTSerialize_pubrel ( char *  buf,
int  buflen,
int  dup,
int  packetid 
)

Serializes a pubrel packet into the supplied buffer.

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
dupinteger - the MQTT dup flag
packetidinteger - the MQTT packet identifier
Returns
serialized length, or error if 0
int MQTTSerialize_suback ( char *  buf,
int  buflen,
int  packetid,
int  count,
int *  grantedQoSs 
)

Serializes the supplied suback data into the supplied buffer, ready for sending

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
packetidinteger - the MQTT packet identifier
count- number of members in the grantedQoSs array
grantedQoSs- array of granted QoS
Returns
the length of the serialized data. <= 0 indicates error
int MQTTSerialize_subscribe ( char *  buf,
int  buflen,
int  dup,
int  packetid,
int  count,
MQTTString  topicFilters[],
int  requestedQoSs[] 
)

Serializes the supplied subscribe data into the supplied buffer, ready for sending

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied bufferr
dupinteger - the MQTT dup flag
packetidinteger - the MQTT packet identifier
count- number of members in the topicFilters and reqQos arrays
topicFilters- array of topic filter names
requestedQoSs- array of requested QoS
Returns
the length of the serialized data. <= 0 indicates error
int MQTTSerialize_subscribeLength ( int  count,
MQTTString  topicFilters[] 
)

Determines the length of the MQTT subscribe packet that would be produced using the supplied parameters

Parameters
countthe number of topic filter strings in topicFilters
topicFiltersthe array of topic filter strings to be used in the publish
Returns
the length of buffer needed to contain the serialized version of the packet
int MQTTSerialize_unsuback ( char *  buf,
int  buflen,
int  packetid 
)

Serializes the supplied unsuback data into the supplied buffer, ready for sending

Parameters
bufthe buffer into which the packet will be serialized
buflenthe length in bytes of the supplied buffer
packetidinteger - the MQTT packet identifier
Returns
the length of the serialized data. <= 0 indicates error
int MQTTSerialize_unsubscribe ( char *  buf,
int  buflen,
int  dup,
int  packetid,
int  count,
MQTTString  topicFilters[] 
)

Serializes the supplied unsubscribe data into the supplied buffer, ready for sending

Parameters
bufthe raw buffer data, of the correct length determined by the remaining length field
buflenthe length in bytes of the data in the supplied buffer
dupinteger - the MQTT dup flag
packetidinteger - the MQTT packet identifier
count- number of members in the topicFilters array
topicFilters- array of topic filter names
Returns
the length of the serialized data. <= 0 indicates error
int MQTTSerialize_unsubscribeLength ( int  count,
MQTTString  topicFilters[] 
)

Determines the length of the MQTT unsubscribe packet that would be produced using the supplied parameters

Parameters
countthe number of topic filter strings in topicFilters
topicFiltersthe array of topic filter strings to be used in the publish
Returns
the length of buffer needed to contain the serialized version of the packet
int MQTTstrlen ( MQTTString  mqttstring)

Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string

Parameters
mqttstringthe string to return the length of
Returns
the length of the string
char readChar ( char **  pptr)

Reads one character from the input buffer.

Parameters
pptrpointer to the input buffer - incremented by the number of bytes used & returned
Returns
the character read
int readInt ( char **  pptr)

Calculates an integer from two bytes read from the input buffer

Parameters
pptrpointer to the input buffer - incremented by the number of bytes used & returned
Returns
the integer value calculated
int readMQTTLenString ( MQTTString *  mqttstring,
char **  pptr,
char *  enddata 
)
Parameters
mqttstringthe MQTTString structure into which the data is to be read
pptrpointer to the output buffer - incremented by the number of bytes used & returned
enddatapointer to the end of the data: do not read beyond
Returns
1 if successful, 0 if not
void writeChar ( char **  pptr,
char  c 
)

Writes one character to an output buffer.

Parameters
pptrpointer to the output buffer - incremented by the number of bytes used & returned
cthe character to write
void writeCString ( char **  pptr,
char *  string 
)

Writes a "UTF" string to an output buffer. Converts C string to length-delimited.

Parameters
pptrpointer to the output buffer - incremented by the number of bytes used & returned
stringthe C string to write
void writeInt ( char **  pptr,
int  anInt 
)

Writes an integer as 2 bytes to an output buffer.

Parameters
pptrpointer to the output buffer - incremented by the number of bytes used & returned
anIntthe integer to write